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 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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 摘要。