fix(openapi): let operation parameters override path-level ones - #7209
Open
1aifanatic wants to merge 2 commits into
Open
1aifanatic wants to merge 2 commits into
1aifanatic wants to merge 2 commits into
Conversation
_collect_operations() appended every path-level parameter to each operation's parameters. An operation-level parameter with the same name and location overrides the path-level one (OpenAPI Path Item Object), so keeping both asked the model for the same path value twice, as account_id and account_id_0. Both map to the same placeholder, and the path-level value won, dropping the operation's more specific parameter. Skip path-level parameters whose (name, in) the operation already declares. Fixes google#7205 Claude-Session: https://claude.ai/code/session_013vXxD1ga1hnCq2uFRwNks7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
OpenApiSpecParser._collect_operations()appended every path-level parameter to each operation's own parameters. Per the OpenAPI 3 Path Item Object, an operation-level parameter with the samenameandinoverrides the path-level one. Keeping both made the tool ask the model for the same path value twice (account_idandaccount_id_0, both required). Both map to the same{accountId}placeholder, and the path-level value won, so the operation's own, more specific parameter was dropped from the request.Solution:
Skip path-level parameters whose
(name, in)the operation already declares. Parameters with the same name but a different location are still merged. References are resolved before this step, so parameters are plain dicts here; anything without anameis left untouched.Testing Plan
Unit Tests:
test_openapi_spec_parser.py::test_parse_spec_operation_parameter_overrides_path_level_parameter: the pathaccountIdis overridden and keeps the operation's description, while a same-namedheaderparameter is still merged. Fails onmain.Every failure outside the new tests also fails on an unmodified
origin/main(3f4bb8f) on the same machine, where the same run gives 47 failed. Most are deterministic Windows-specific tests (cli/deploy, conformance,scripts/check_new_py_files, path normalization, the unsafe local code executor, the import allowlist, yaml). The remainder differ between runs: telemetry functional/node-functional schema cases, andstreaming/test_streaming_tool_events.py::test_delivered_event_carries_the_message_and_nothing_else, which failed 1/10 in isolation on cleanmainversus 2/10 on this branch. I ran on Python 3.12 only, not the fulltoxmatrix.Manual End-to-End (E2E) Tests:
An
OpenAPIToolsetwhose/accounts/{accountId}path declaresaccountIdand whoseGEToverrides it; HTTP goes to anhttpx.MockTransport. The script is in #7205.Before (
main@ 3f4bb8f):After:
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_013vXxD1ga1hnCq2uFRwNks7