fix(azure): build responses input_items url with path before query string - #32270
Conversation
Greptile SummaryThis PR fixes a URL construction bug in
Confidence Score: 5/5The change is a well-scoped, correctly implemented bug fix with a targeted regression test; safe to merge. The root cause (string concatenation after the query string) is fully addressed by injecting the suffix into the structured path component before No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/azure/responses/transformation.py | Adds optional path_suffix to _construct_url_for_response_id_in_path; refactors transform_list_input_items_request and transform_cancel_response_api_request to use the shared helper correctly. Fix is logically sound — suffix is appended to the path tuple component, not the fully-assembled string. |
| tests/test_litellm/llms/azure/response/test_azure_transformation.py | Adds a new unit test test_azure_list_input_items_request_url_path_before_query that uses no real network calls and correctly asserts the exact URL shape after the fix. |
Reviews (3): Last reviewed commit: "chore(azure): drop stale inline comment ..." | Re-trigger Greptile
Greptile SummaryThis PR fixes a URL-construction bug in the Azure Responses API where
Confidence Score: 5/5The change is a tightly scoped, well-tested URL-construction fix with no side effects on other providers or request paths. Both affected callers pass statically-known, slash-prefixed suffix strings, the shared helper is covered by existing tests plus the new regression test, and the cancel refactor is a pure de-duplication with identical behavior. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/azure/responses/transformation.py | Adds path_suffix parameter to _construct_url_for_response_id_in_path so suffixes like /input_items and /cancel are inserted into the URL path before the query string is reattached; also de-duplicates the cancel-URL construction that had the same logic inline. |
| tests/test_litellm/llms/azure/response/test_azure_transformation.py | Adds a regression test asserting that /input_items appears before ?api-version=... in the constructed URL, which fails on the old concatenation approach and passes with the fix. |
Comments Outside Diff (1)
-
litellm/llms/azure/responses/transformation.py, line 228 (link)The inline comment on this line is now stale —
new_pathcarries both theresponse_idand the optionalpath_suffix(e.g./input_items,/cancel). A reader looking at the comment alone would not know the suffix is included.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (2): Last reviewed commit: "fix(azure): build responses input_items ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Relevant issues
Found while investigating a customer report on Responses API follow-up calls failing for Azure deployments
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
Live proxy (dbless,
disable_responses_id_security: true) with a real Azure OpenAI deployment (azure/gpt-4o, api_version2025-03-01-preview)Before (staging f628b41), the proxy called a malformed upstream URL where
/input_itemswas appended after the query string, per the proxy debug logand the client saw Azure's 404 body wrapped in an HTTP 200
After the fix, the same two curls hit the correct upstream URL
and return the real item list
As a side observation: the upstream 404 body was being passed through as an HTTP 200 to the client, masking the failure. That masking disappears here because the URL is now correct, but the response-status handling for list input items may deserve its own look
Type
🐛 Bug Fix
Changes
GET /v1/responses/{id}/input_itemsforazure/models built the upstream URL by string-concatenating"/input_items"onto the output of_construct_url_for_response_id_in_path, which already contains the?api-version=...query string. Azure therefore received.../responses/{id}?api-version=.../input_itemsand returned 404 Resource not foundAzureOpenAIResponsesAPIConfig._construct_url_for_response_id_in_pathnow takes apath_suffixparameter that is inserted into the URL path before the query string is reattached.transform_list_input_items_requestpasses"/input_items"through it, andtransform_cancel_response_api_request(which had duplicated the same parse/unparse logic inline for/cancel) now reuses the shared helper. Get and delete URL building already used the helper and are unchanged. The OpenAI config builds its input_items URL from a query-less api_base, so other providers are unaffectedRegression test added in
tests/test_litellm/llms/azure/response/test_azure_transformation.pyasserting the exact input_items URL with the path segment before the query string; it fails on the previous concatenation behavior