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

Aperta Adatta ai principianti
#7,838 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@llalitkumarrr ci sta già lavorando.

Dal 30/10/2026.

  • #7839 di @adityasingh2400 — aperta
  • #7848 di @ninglinLiu — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Individua RestApiTool._prepare_request_params e confronta l’accesso allo schema grezzo del corpo della richiesta con la normalizzazione _schema_from_openapi di OperationParser. Riproduci il problema usando l’Operation fornita, MediaType() e un valore del corpo composto da byte. Il problema è risolto quando la chiamata non genera più un’eccezione e invia i byte con Content-Type: application/octet-stream; l’issue non indica un file di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🔴 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
Lingua principale
Python
Stelle
22.1k
Fork
4.3k
Merge medio
1g 10h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google/adk-python

Tutte le issue di google/adk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.