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

未關閉 適合新手
#7,838 2 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 4 天內回覆

@llalitkumarrr 已經在處理了。

開始於 2026年10月30日。

  • #7839 來自 @adityasingh2400 —— 未關閉
  • #7848 來自 @ninglinLiu —— 已關閉,未合併

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

找出 RestApiTool._prepare_request_params,並將其對原始請求本文 schema 的存取方式與 OperationParser 的 _schema_from_openapi 正規化進行比較。使用提供的 Operation、MediaType() 和位元組型別的本文值重現問題。完成條件是呼叫不再引發例外,並以 Content-Type: application/octet-stream 傳送位元組;issue 未指定測試檔案。

由索引模型根據 Issue 內容生成。

描述

core

🔴 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
主要語言
Python
星號
22.1k
分支
4.3k
平均合併
1 天 10 小時
30 天內合併 PR
5

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。