Skip to content

Fix parse_azure_endpoint passing query string to AsyncAzureOpenAI#231

Merged
gvanrossum merged 2 commits intomicrosoft:mainfrom
KRRT7:fix/parse-azure-endpoint
Apr 10, 2026
Merged

Fix parse_azure_endpoint passing query string to AsyncAzureOpenAI#231
gvanrossum merged 2 commits intomicrosoft:mainfrom
KRRT7:fix/parse-azure-endpoint

Conversation

@KRRT7
Copy link
Copy Markdown
Contributor

@KRRT7 KRRT7 commented Apr 10, 2026

Stack: 1/4 — merge this first, then #229, #230, #232.


  • parse_azure_endpoint returned the full URL including ?api-version=...
  • AsyncAzureOpenAI appends /openai/ to azure_endpoint, producing a mangled URL with the query string in the path
  • Now strips the query string with str.split("?", 1)[0] before returning
  • Added 6 unit tests covering: basic URL, no version, separate env var, missing env var, empty query string

Benchmark

No performance impact — this is a correctness fix.


Generated by codeflash optimization agent

KRRT7 added 2 commits April 9, 2026 22:45
uv 0.10.x is current; the <0.10.0 constraint caused build warnings.
parse_azure_endpoint returned the raw URL including ?api-version=...
which AsyncAzureOpenAI then mangled into invalid paths like
...?api-version=2024-06-01/openai/. Strip the query string before
returning — api_version is already returned as a separate value and
passed to the SDK independently.
Copy link
Copy Markdown
Collaborator

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@gvanrossum gvanrossum merged commit 02ca2d2 into microsoft:main Apr 10, 2026
16 checks passed
@bmerkle
Copy link
Copy Markdown
Collaborator

bmerkle commented Apr 13, 2026

this break current setup, e.g. .env files containing URLs with api version information (which is the default in Azure Foundry setup).
please see bugreport #238

bmerkle added a commit to bmerkle/typeagent-py that referenced this pull request Apr 13, 2026
 Updated parse_azure_endpoint in utils.py:200 to strip the /openai/deployments/... path from the endpoint URL. Previously it only removed the query string, leaving the full deployment path — which AsyncAzureOpenAI then duplicated, causing the 404.

 Updated test_online.py to use create_chat_model() → model._model.request() — the same _make_azure_provider → AzureProvider(openai_client=AsyncAzureOpenAI(...)) code path used by the rest of the codebase.
gvanrossum pushed a commit that referenced this pull request Apr 14, 2026
fixes bugs described in #238 
- regression URL parsing in PR #231
- uv.lock updated to newer versions in many cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants