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

Aperta Adatta ai principianti
#2,875 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@n1dhruv ci sta già lavorando.

Dal 21/11/2026.

  • #2924 di @MaxonT — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
cli

Direzione di ricerca

Inizia in src/core/invokeRuntime.ts, nel ramo !response.ok di invokeRuntimeWithCustomJwt (intorno alle righe 170-178), dove il body viene annullato e sopravvivono solo status/headers. Leggi il body con una lettura limitata prima di annullare, esegui il parse di error.message per i body JSON-RPC e di message per JSON semplice, e ricadi sulla riga di stato esistente quando è vuoto o non analizzabile; controlla anche il percorso di output --json in modo che entrambi i campi siano inclusi. Fatto quando un'invocazione rifiutata contro un runtime reale stampa il tipo di errore e il messaggio su stderr e gli stessi campi compaiono in --json.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
339
Fork
129
Merge medio
19h 21m
PR unite (30g)
125

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/agentcore-cli

Tutte le issue di aws/agentcore-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.