Skip to content

fix(invoke): show error type and message for rejected CUSTOM_JWT invocations - #2924

Open
MaxonT wants to merge 1 commit into
aws:v1.xfrom
MaxonT:contrib/2875-auto
Open

MaxonT wants to merge 1 commit into
aws:v1.xfrom
MaxonT:contrib/2875-auto

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 25, 2026

Copy link
Copy Markdown

When a CUSTOM_JWT runtime rejects a call, invoke now shows the response body and error type, such as "Token has expired", instead of dropping them; I only had the issue title, so other error shapes may need checking.

When a CUSTOM_JWT Runtime invocation returns a non-2xx response, invokeRuntimeWithCustomJwt currently cancels the body and only reports the status, so a rejected token gives error=HTTP 401 request-id=... with no reason. Thank you to the reporter for the clear curl comparison and acceptance list; I followed it.

This change reads a bounded amount of the rejected response (at most 4 KiB, with a 2 s read timeout) together with the x-amzn-errortype header, and adds errorType and message to the rejected response's error. The message is taken from a JSON-RPC body (error.message) or a plain JSON body (message/Message), whitespace-collapsed and capped at 500 characters. The stderr summary now reads, for example, error=HTTP 401 UnrecognizedClientException: Token has expired request-id=.... An empty, non-JSON or unexpected body falls back to the existing status line. Both --json and plain output use this same summary line, so they carry the same fields.

Tests: added cases in src/core/core.test.ts (JSON-RPC body plus header, plain JSON body, empty/unparseable/non-string bodies, oversized body) and in src/handlers/runtime/invoke/response.test.ts (summary text). bun test src/core/core.test.ts src/handlers/runtime/invoke passes (56 tests in the two touched files), tsc --noEmit is clean, and the three new behavior tests fail with the source change reverted.

Not verified: no real CUSTOM_JWT Runtime or expired token was available, so the behavior was checked against mocked fetch responses only. The interactive TUI screen (runtime/invoke/screen.tsx) was not changed and still shows status and request ID only. The full bun test suite was not run, only the touched areas plus src/handlers/project/invoke.

Refs #2875

…cations

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
@MaxonT
MaxonT requested a review from a team November 25, 2026 11:26
@github-actions github-actions Bot added the size/m PR size: M label Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant