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

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

Maintainer thường phản hồi trong vòng 1 ngày

@n1dhruv đang làm issue này rồi.

Từ ngày 21/11/2026.

  • #2924 của @MaxonT — đang mở

Đá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
82/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ệ
node.js, typescript
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu trong src/core/invokeRuntime.ts, trong nhánh !response.ok của invokeRuntimeWithCustomJwt (khoảng dòng 170-178), nơi body bị hủy và chỉ còn lại status/headers. Đọc body bằng một lần đọc có giới hạn trước khi hủy, parse error.message cho các body JSON-RPC và message cho JSON thuần, và fallback về dòng status hiện có khi rỗng hoặc không parse được; đồng thời kiểm tra đường xuất --json để cả hai trường được bao gồm. Hoàn tất khi một invocation bị từ chối với runtime thật in ra loại lỗi và thông điệp ra stderr và các trường tương tự xuất hiện trong --json.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
339
Fork
129
Merge trung bình
19 giờ 21 phút
Pull request đã merge (30 ngày)
125

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 aws/agentcore-cli

Tất cả issue của aws/agentcore-cli

Issue tương tự

Thêm issue về TypeScript

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.