RestApiTool raises uncaught KeyError when a required path param is omitted
Maintainer thường phản hồi trong vòng 5 ngày
@llalitkumarrr đang làm issue này rồi.
Từ ngày 28/9/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu trong google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py, tập trung vào _prepare_request_params và RestApiTool.call. Tái hiện trường hợp thiếu user_id bằng thiết lập unit test ngoại tuyến và lần theo lỗi định dạng đường dẫn. Được xem là hoàn tất khi các tham số đường dẫn bắt buộc bị bỏ qua tạo ra một lỗi công cụ có cấu trúc và có thể thử lại, thay vì một KeyError không được bắt hoặc một lần gọi agent bị hủy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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_namesfor the param includeuser_id(declaration expects snake_case), but missing value still crashes viaformat
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.
- Ngôn ngữ chính
- Python
- Star
- 21.6k
- Fork
- 4k
- Merge trung bình
- 12 giờ 6 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google/adk-python#7341 · 2 reaction ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
google/adk-python#7334 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 5 ngày
-
GoogleOidcVerifier treats string "false" as a verified email claimCó thể đã có người làm @surajksharma07 đã nhận 1 ngày trước. Đang mởcore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
google/adk-python#7289 · 5 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 5 ngày
-
CredentialsManager should also extract scopes when populating auth schemesCó thể đã có người làm @sanketpatil06 đã nhận 4 ngày trước. Đang mởcore needs review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7266 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 5 ngày
-
OAuth2 Discovery method fails because FastMCP with GoogleProvider (OAuth) returns issuerUrl with trailing slashCó thể đã có người làm @sanketpatil06 đã nhận 4 ngày trước. Đang mởmcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7265 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của google/adk-python
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
https://search.utilibre.orgĐang mởinstance instance add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
searxng/searx-instances#941 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
FluidNumerics/fluid-walk-blocker#89 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày