Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base_url property in request_adapter.http_client is not used by HttpXRequestAdapter #374

Open
jimisola opened this issue Oct 15, 2024 · 2 comments
Labels
Needs: Attention 👋 python Pull requests that update Python code type:bug A broken experience

Comments

@jimisola
Copy link

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Python

Describe the bug

AsyncClient.base_url is not used by HttpxRequestAdapter as expected.

      http_asyncclient: AsyncClient = AsyncClient(
            base_url=self.stimulator_config.server.base_url,  # BUG base_url not used, file issue with kiota
            ),
            headers=headers,
        )
        request_adapter: HttpxRequestAdapter = HttpxRequestAdapter(
            authentication_provider=auth_provider,
            http_client=http_asyncclient,
            # base_url=app_config.server.base_url, # base_url must be set here         )
        client: ApiClient = ApiClient(request_adapter=request_adapter)

Expected behavior

HttpxRequestAdapter uses HttpxRequestAdapter.http_client.base_url

How to reproduce

See above.

Open API description file

No response

Kiota Version

1.18.0

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

Set base_url in

Configuration

  • Linux (Ubuntu)

Debug output

Click to expand log ```
</details>


### Other information

We are using microsoft-kiota-http==1.3.3 (HttpxRequestAdapter). I updated to 1.3.4 but the constructor of HttpxRequestAdapter has not changed from what I can see.

See: https://github.com/microsoft/kiota-http-python/blob/main/kiota_http/httpx_request_adapter.py#L90

@jimisola jimisola added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Oct 15, 2024
@msgraph-bot msgraph-bot bot added the python Pull requests that update Python code label Oct 15, 2024
@baywet baywet transferred this issue from microsoft/kiota Oct 15, 2024
@baywet
Copy link
Member

baywet commented Oct 15, 2024

Hi @jimisola
Thank you for using kiota and for reaching out.

You are correct, in dotnet, if a base url is set on the underlying HTTP client, it's used by the request adapter.
https://github.com/microsoft/kiota-dotnet/blob/650812d9b598f192e6e55424e327d2bcee49c99a/src/http/httpClient/HttpClientRequestAdapter.cs#L52

This is something that could be fixed by adding a couple of conditions here

(explicitly passed base URL should take precedence over the one from the underlying http client)

By reading the base url property
https://github.com/encode/httpx/blob/1bf1fc0ea8417c8e539914aeafdb48f15591ba75/httpx/_client.py#L268

Is this something you'd like to submit a pull request for provided some guidance?

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Oct 15, 2024
@baywet baywet moved this from Needs Triage 🔍 to Todo 📃 in Kiota Oct 15, 2024
@jimisola
Copy link
Author

Hi @baywet

Thanks for confirming the issue.

The fix is normally the easy thing whereas getting to know the project, i.e. how to build, test, do code formatting etc is usually what takes time.

I can have a look at it but I don't know when due to deadlines at work and some involvement in some other open source projects.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention 👋 python Pull requests that update Python code type:bug A broken experience
Projects
Status: Todo 📃
Development

No branches or pull requests

2 participants