`core.getIDToken` discards the original error, so callers cannot tell a network failure from an HTTP error

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Trova l’implementazione di core.getIDToken nel toolkit e leggi la gestione degli errori relativa alla richiesta del token non riuscita. Controlla come i test coprono i problemi di rete e gli errori HTTP, quindi esegui i test pertinenti. Il lavoro è completato quando l’errore generato mantiene l’errore originale come cause, conservando campi come code e statusCode.

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

Descrizione

What happened?

core.getIDToken sometimes fails because of a transient network error, for
example socket hang up or a TLS disconnect (see #2098 and #1441). An action
that calls getIDToken should be able to retry those failures and fail fast on
a real HTTP error, such as a 403.

The action cannot do that. getIDToken throws a new Error that holds only a
formatted message. The original error is not attached as cause, and the
thrown error has no code or statusCode. The only way to tell a dropped
connection from a 403 is to parse the message text.

Example

A local server stands in for ACTIONS_ID_TOKEN_REQUEST_URL. In one case it
destroys the socket. In the other case it returns 403. With @actions/core
3.0.1:

try { await core.getIDToken('aud') }
catch (e) { console.log({ message: e.message, cause: e.cause, code: e.code, statusCode: e.statusCode }) }
== socket destroyed
{ message: 'Error message: Failed to get ID Token. \n \n        Error Code : undefined\n \n        Error Message: socket hang up',
  cause: undefined, code: undefined, statusCode: undefined }
== HTTP 403
{ message: 'Error message: Failed to get ID Token. \n \n        Error Code : 403\n \n        Error Message: forbidden',
  cause: undefined, code: undefined, statusCode: undefined }

Expected: The thrown error keeps the original error as cause, so a caller
can read cause.code (ECONNRESET) or cause.statusCode (403).

Lingua principale
TypeScript
Stelle
5.9k
Fork
1.8k
Merge medio
15m
PR unite (30g)
1

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 actions/toolkit

Tutte le issue di actions/toolkit

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.