Skip to content

RestApiTool crashes on a request body media type that has no schema #7838

Description

@adityasingh2400

🔴 Required Information

Describe the Bug:
A RestApiTool whose request body declares a media type without a schema (OpenAPI allows content: {application/octet-stream: {}}) crashes when called:

AttributeError: 'NoneType' object has no attribute 'type'

OperationParser handles this case: it normalizes the schema with _schema_from_openapi, where None becomes Schema(), and exposes a single body parameter. RestApiTool._prepare_request_params then reads media_type_object.schema_ raw and calls .type on None. So the tool is generated and offered to the model, but every call fails. mypy already reports these lines (Item "None" of "Schema | Reference | Any | None" has no attribute "type").

Steps to Reproduce:

op = Operation(
    operationId="upload_contract",
    requestBody=RequestBody(content={"application/octet-stream": MediaType()}),
)
params = OperationParser(op).get_parameters()   # [body]
tool = RestApiTool(name="upload_contract", description="...", endpoint=..., operation=op)
tool._prepare_request_params(params, {"body": b"%PDF-1.7"})

Expected Behavior:
The bytes are sent as the request body with Content-Type: application/octet-stream.

Observed Behavior:
AttributeError: 'NoneType' object has no attribute 'type'

Environment Details:

  • ADK Library Version (pip show google-adk): 2.13.0 (also on main at 75fb788)
  • Desktop OS: macOS
  • Python Version (python -V): 3.11.16

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A (tool request building)

🟡 Optional Information

How often has this issue occurred?:

  • Always (100%), for request bodies whose media type has no schema

Activity

  1. adityasingh2400 commented on Oct 31, 2026

    @adityasingh2400
    ContributorAuthor

    For triage: #7839 has been open for this since the issue was filed (Oct 29, 19:08 UTC). #7848 was opened about three hours later for the same bug. Happy to consolidate however you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions