invoke: CUSTOM_JWT runtime errors discard the response body and error type (e.g. "Token has expired")

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

維護者通常 1 天內回覆

@n1dhruv 已經在處理了。

開始於 2026年11月21日。

  • #2924 來自 @MaxonT —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
cli

研究方向

從 src/core/invokeRuntime.ts 開始,在 !response.ok 分支中(invokeRuntimeWithCustomJwt 的,大約第 170-178 行),這裡 body 會被取消,只有 status/headers 會保留。在取消之前用有界讀取讀取 body,對 JSON-RPC body 解析 error.message,對一般 JSON 解析 message,當為空或無法解析時回退到現有的 status 行;還要檢查 --json 輸出路徑,以便兩個欄位都包含在內。當針對真實 runtime 的被拒絕 invocation 將錯誤類型與訊息列印到 stderr,且相同欄位出現在 --json 中時,即完成。

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

描述

bug
Description

When a CUSTOM_JWT Runtime invocation returns a non-2xx response, the CLI discards the response body and the x-amzn-errortype header, so the reason for the failure never reaches the user.

In src/core/invokeRuntime.ts (invokeRuntimeWithCustomJwt), the !response.ok branch reads the request ID, then calls response.body?.cancel() and returns only status and header metadata.

Since #2751 (1.0.2) a status line is printed to stderr. Before that (1.0.1) nothing was printed at all.

Steps to Reproduce
  1. Have a Runtime with a CUSTOM_JWT authorizer.
  2. Invoke it with an expired token:
    agentcore invoke --runtime <name> --bearer-token "$EXPIRED_TOKEN" --payload '{"prompt":"hi"}'
Expected Behavior

stderr includes the error type and the message from the response body, for example:

Error: HTTP 401 UnrecognizedClientException: Token has expired (request-id=<id>)
Actual Behavior

1.0.2+ prints only:

status=401 content-type=... complete=false bytes=0 error=HTTP 401 request-id=<id>

1.0.1 prints nothing and exits 1.

For comparison, the same request with curl returns header x-amzn-errortype: UnrecognizedClientException:<namespace> and body {"jsonrpc":"2.0","error":{"code":-32001,"message":"Token has expired"}}.

CLI Version

1.1.0 (also 1.0.1)

Operating System

Linux

Additional Context

Acceptance:

  • On a rejected CUSTOM_JWT invocation, read (a bounded amount of) the body and surface the error type and message.
  • Handle both JSON-RPC (error.message) and plain JSON (message) bodies; fall back to the current status line when the body is empty or unparseable.
  • --json output carries the same fields.
主要語言
TypeScript
星號
339
分支
129
平均合併
19 小時 21 分鐘
30 天內合併 PR
125

環境準備

從這裡開始

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

aws/agentcore-cli 的其他 Issue

查看 aws/agentcore-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

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

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