Skip to content

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

Closed

Description

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

Activity

  1. baywet commented on Oct 15, 2024

    @baywet
    Member

    Hi Jimisola Laursen (@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?

  2. moved this from Needs Triage 🔍 to Todo 📃 in Kiotaon Oct 15, 2024
  3. jimisola commented on Oct 16, 2024

    @jimisola
    Author

    Hi Vincent Biret (@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.

  4. added a commit that references this issue on Jan 26, 2025
    7c3582f
  5. added a commit that references this issue on Jan 28, 2025
    e0b0421
  6. moved this from New📃 to Done ✔️ in Kiotaon Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    • Status
      Done ✔️

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions