A 401 with code unauthorized is treated as an expired token and replayed
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
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- backend-api-design
Direzione di ricerca
Inizia da base.Action in base/base.go e dal percorso di retry in b2/backend.go (withReauth); l’issue identifica la classificazione attuale e indica il comportamento richiesto in base al codice di errore. Aggiungi o aggiorna i test httptest per unauthorized, entrambi i codici di errore del token e access_denied con risposte 401 e 403. Il lavoro è completato quando solo gli errori del token attivano una nuova autorizzazione e la ripetizione della richiesta, mentre i codici non ritentabili vengono restituiti senza una richiesta aggiuntiva.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Every HTTP 401 from a native API call (other than b2_authorize_account and uploads) is classified as "re-authenticate", including 401s that have nothing to do with an expired token. Found while reviewing #53.
base.Action (base/base.go) returns ReAuthenticate for any 401 outside b2_authorize_account, b2_upload_file and b2_upload_part, without looking at the error code. withReauth (b2/backend.go) then calls reauthorizeAccount and replays the request once. The B2 spec lists three different 401 codes for b2_delete_file_version (bad_auth_token, expired_auth_token, unauthorized), and only the first two mean the token needs refreshing. unauthorized means the token is valid but the key does not authorize this call with these parameters.
Reproduced with a throwaway httptest test: a b2_delete_file_version response of 401 with code unauthorized is classified as ReAuthenticate. So a caller using b2.BypassGovernance() with a key that lacks the bypassGovernance capability triggers an extra b2_authorize_account call and a second identical delete request before getting the same error back. The cost is bounded (withReauth retries once), but it is wasted work, it hides the real cause behind two failed attempts, and it applies to every operation that returns unauthorized, such as a prefix-restricted key listing outside its prefix (the v4 multi-bucket key case in #30).
The same spec page also leaves the status of the Object Lock access_denied response unclear (401 in one rendering, 403 in another). If it is 401, a locked delete would also be re-authorized and replayed. The code string should decide the action, not the status alone.
What is needed:
- Classify 401 by
code: re-authenticate only forbad_auth_tokenandexpired_auth_token; treatunauthorizedandaccess_deniedas non-retryable (Punt) and surface the message. - Keep the existing behavior for uploads (
AttemptNewUpload) and forb2_authorize_account(Punt). - Decide the behavior for a 401 with an unknown or missing code (keep re-authenticating once, as today, to stay safe).
Acceptance checks:
- An
httptesttest returns401with codeunauthorizedfor a native call and assertsbase.Actionis notReAuthenticateand that exactly one request reaches the server and no extrab2_authorize_accountis made. - The same test with
bad_auth_tokenandexpired_auth_tokenstill re-authenticates and replays once. - A test covers
access_deniedreturned as 401 and as 403.
Related: #53, #30. This overlaps the retry and error classification gaps already noted for base/base.go:92-97.
- Lingua principale
- Go
- Stelle
- 66
- Fork
- 18
- Merge medio
- 1g 10h
- PR unite (30g)
- 132
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Backblaze/blazer
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Bucket.Attrs never returns ReplicationConfig: replication configuration is write-onlyForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
test: skip the fuzz non-vacuity guard when replaying a single seedForse già presa @ffumero2003 l’ha presa 5 giorni fa. Apertatesting
Backblaze/blazer#330 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
test: add fuzz targets for the untrusted-input parsers that lack oneForse già presa @ffumero2003 l’ha presa 5 giorni fa. Apertatesting
Backblaze/blazer#325 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Backblaze/blazer
Issue simili
-
needs-triage typo
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
llm-d-incubation/llm-d-scaling-manager#122 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue severity: low tech-debt
Difficoltà 2/5 Mezza giornata Idoneità per principianti 75/100
TMHSDigital/subenum#329 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Backend summarize min() / max() panics when a field has no numeric valuesForse già presa @weng5e l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
grafana/grafana-infinity-datasource#1832 ·
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
GillMacedo/godebugdiff#13 ·