Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

RestApiTool raises uncaught KeyError when a required path param is omitted

Đang mở Phù hợp với người mới
#7,282 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
openapi, python
Lĩnh vực
api, backend

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ả

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.

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/adk-python

Tất cả issue của google/adk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.