fix(tools): send the body for oneOf/anyOf/allOf OpenAPI request schemas - #6992
Open
chelsealong wants to merge 1 commit into
Open
fix(tools): send the body for oneOf/anyOf/allOf OpenAPI request schemas#6992chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
OperationParser names a polymorphic or untyped request body parameter 'body' (instead of '' used for plain scalar bodies) to avoid emitting an empty-named property in the function declaration. RestApiTool's _prepare_request_params only recognized the '' sentinel, so it never matched the 'body'-named parameter and silently sent no body at all. Fixes google#6991
chelsealong
force-pushed
the
fix-6991-oneof-body-silently-dropped
branch
from
September 3, 2026 00:33
45c873e to
5d203a1
Compare
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.
Fixes #6991
Problem
For an OpenAPI operation whose request body schema is polymorphic (
oneOf,anyOf,allOf) or has notype,RestApiToolbuilds a correct functiondeclaration with a
bodyparameter, the model supplies that argument — andthe HTTP request is sent with no body at all. No exception, no warning,
no log line;
Content-Type: application/jsonis still set, so the serverreceives a well-formed request with
Content-Length: 0.Root cause
OperationParser._process_request_bodynames a polymorphic/untyped bodyparameter
'body'(instead of'') specifically to avoid emitting anempty-named property in the function declaration (this was the fix for
#2213).
RestApiTool._prepare_request_params, however, only recognized thelegacy
''sentinel when deciding which parameter represents the full body:Since a polymorphic/untyped schema's parameter is named
'body', not'',this condition never matches,
body_datastaysNone, andjsonis neverset on the outgoing request — silently.
Fix
_prepare_request_paramsnow treats both''and'body'as the full-bodysentinel, matching what
OperationParseractually emits:Test plan
Added
test_prepare_request_params_oneof_body, which builds aoneOfrequest body schema (mirroring the issue's
{card}/{iban}example) andasserts the constructed request actually carries the JSON body.
Confirmed the new test fails without the fix (
git checkout HEAD~1 -- src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py):And passes with the fix restored:
Full
openapi_toolsuite and the broadertoolssuite also pass:Formatting/lint checked with the repo's configured tools:
Disclosure
This PR was prepared with the assistance of an AI coding agent (Claude),
under human review before submission.