Skip to content

OpenAPIToolset drops required request body properties #6503

Description

@benclarkeio

🔴 Required Information

Describe the Bug:

When OperationParser expands an object request body into function parameters, it does not copy the schema required list into ApiParameter.required. As a result, required request-body properties are omitted from the generated function declaration required list and appear optional to the model.

Steps to Reproduce:

  1. Parse an operation containing this request-body schema:
type: object
required:
  - spaceName
  - tmsZoneId
properties:
  spaceName:
    type: string
  tmsZoneId:
    type: string
  description:
    type: string
  1. Inspect OperationParser.get_parameters() or get_json_schema().

Expected Behavior:

spaceName and tmsZoneId have required=True and appear in the generated JSON Schema required list. description remains optional.

Observed Behavior:

All three body parameters have required=False:

[("spaceName", False), ("tmsZoneId", False), ("description", False)]

This makes generated tool signatures advertise required API fields as optional, allowing the model to omit them and send invalid requests.

Environment Details:

  • ADK Library Version: reproduced with 2.0.0 and current main at fb55d4a669e35fd9da69bbb951945d1a19792f9f
  • Desktop OS: macOS
  • Python Version: 3.13.5

Model Information:

  • Are you using LiteLLM: N/A
  • Which model is being used: N/A; this reproduces directly in the OpenAPI parser

🟡 Optional Information

Regression:

The related fix in #256 propagated required for regular operation parameters, but _process_request_body does not apply the object schema required list when it constructs flattened body parameters.

Additional Context:

For object bodies, the fix can derive required_properties = set(schema.required or []) and pass required=prop_name in required_properties when constructing each ApiParameter. I am preparing a focused PR with a regression test.

Minimal Reproduction Code:

from fastapi.openapi.models import MediaType, Operation, RequestBody, Schema
from google.adk.tools.openapi_tool.openapi_spec_parser.operation_parser import OperationParser

operation = Operation(
    operationId="createSpace",
    requestBody=RequestBody(
        required=True,
        content={
            "application/json": MediaType(
                schema=Schema(
                    type="object",
                    required=["spaceName", "tmsZoneId"],
                    properties={
                        "spaceName": Schema(type="string"),
                        "tmsZoneId": Schema(type="string"),
                        "description": Schema(type="string"),
                    },
                )
            )
        },
    ),
)

parser = OperationParser(operation)
print([
    (parameter.original_name, parameter.required)
    for parameter in parser.get_parameters()
])

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions