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

Offen Anfängerfreundlich
#2,875 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@n1dhruv arbeitet bereits daran.

Seit 21.11.2026.

  • #2924 von @MaxonT — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
82/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
node.js, typescript
Bereich
cli

Rechercherichtung

Beginne in src/core/invokeRuntime.ts, im !response.ok-Zweig von invokeRuntimeWithCustomJwt (etwa Zeilen 170-178), wo der Body abgebrochen wird und nur Status/Header erhalten bleiben. Lies den Body mit einem begrenzten Lesevorgang, bevor du abbrichst, parse error.message für JSON-RPC-Bodies und message für reines JSON, und falle auf die vorhandene Statuszeile zurück, wenn er leer oder nicht parsebar ist; prüfe außerdem den --json-Ausgabepfad, damit beide Felder enthalten sind. Fertig, wenn eine abgelehnte Invocation gegen eine echte Runtime den Fehlertyp und die Meldung nach stderr ausgibt und dieselben Felder in --json erscheinen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.
Vorherrschende Sprache
TypeScript
Sterne
339
Forks
129
Ø Merge
19 Std. 21 Min.
Gemergte PRs (30 T.)
125

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aws/agentcore-cli

Alle Issues in aws/agentcore-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.