Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

RestApiTool raises uncaught KeyError when a required path param is omitted

Aperta Adatta ai principianti
#7,282 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

@llalitkumarrr ci sta già lavorando.

Dal 28/9/2026.

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
openapi, python
Ambito
api, backend

Direzione di ricerca

Inizia da google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py, concentrandoti su _prepare_request_params e RestApiTool.call. Riproduci il caso di user_id mancante con la configurazione dei test unitari offline e traccia l'errore di formattazione del percorso. Il lavoro è concluso quando i parametri di percorso obbligatori omessi producono un errore dello strumento strutturato e ripetibile, invece di un KeyError non intercettato o di un'invocazione dell'agente interrotta.

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

Descrizione

request clarification tools
Description

FunctionTool returns {"error": ...} when mandatory args are missing so the model can retry.

RestApiTool maps filled args into path_params, then does self.endpoint.path.format(**path_params) in _prepare_request_params. An omitted required path parameter leaves a template key unset → KeyError (original OpenAPI name, e.g. 'userId').

RestApiTool.call only catches TimeoutException / HTTPStatusError, so the agent invocation aborts instead of returning a retryable tool error.

Location: google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py

Environment
  • google-adk==2.9.2
  • Offline unit repro (no live HTTP)
Repro
# RestApiTool for path /users/{userId} with required path param userId / py_name user_id
# Call with args {} (or missing user_id)
# → KeyError: 'userId'
Observed (google-adk==2.9.2)
  • path /users/{userId}, args {} → KeyError: 'userId'
  • py_names for the param include user_id (declaration expects snake_case), but missing value still crashes via format
Expected

Missing required path params should return a structured tool error (mirror FunctionTool._get_mandatory_args) so the model can retry, not abort the agent run.

Suggested fix

Before format, verify every {placeholder} in the path is present; on miss return {"error": "missing path parameter …"}. Optionally catch KeyError/ValueError from _prepare_request_params in call.

Notes

Nearby RestApiTool crashes #7164 (header type) and #7206 (non-UTF-8 body) are different sites. Happy to open a PR.

Lingua principale
Python
Stelle
21.6k
Fork
4k
Merge medio
12h 6m
PR unite (30g)
4

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.