Define behavior when several X-Bz-Test-Mode options are enabled

Aperta
#100 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Start with base/base.go at addHeaders and the request paths makeRequest and DownloadFileByName; read the README section and the review context in #49. First determine how B2 handles repeated or comma-separated X-Bz-Test-Mode values, using a live account or asking Backblaze. Then add httptest coverage for each option and combinations, including ForceCapExceeded() on upload and download; done when tests assert the sent headers and the README records the verified behavior.

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

Descrizione

enhancement

Enabling more than one test-mode option sends several X-Bz-Test-Mode header lines, and Backblaze does not document that this works. Raised in review on #49.

addHeaders (base/base.go:270) uses req.Header.Add("X-Bz-Test-Mode", ...) for each enabled option. FailSomeUploads(), ExpireSomeAuthTokens() and ForceCapExceeded() can all be passed to b2.NewClient (and base.AuthorizeAccount), so combining them produces up to three separate X-Bz-Test-Mode header lines on every request. Backblaze's Integration Checklist documents each value on its own and says nothing about combining values, by comma or by repeated headers, so what B2 does with repeated lines is unknown: it may honour all, honour only the first or last, or reject the request.

Two related facts from the same review:

  • The header is set once at client construction and sent on every request the client makes (all JSON calls through makeRequest at base/base.go:446, including b2_authorize_account, and DownloadFileByName at base/base.go:1273). There is no way to turn it off for one call.
  • ForceCapExceeded() has no caller or test anywhere in the repo, so the cap-exceeded path has never been exercised.

#49 documents all of this and tells users to prefer one option per client unless they have verified the combination. blazer's own live tests (startLiveTest, b2/integration_test.go) already combine FailSomeUploads() and ExpireSomeAuthTokens(), but that does not establish that every combination, including all three, is supported by B2. This issue is about making the behavior defined rather than only documented with a caveat.

What is needed:

  • Find out what B2 does with repeated X-Bz-Test-Mode lines and with a comma separated value, using a live account (and ask Backblaze if the docs stay silent).
  • Based on the result, either send a single combined header in the form B2 accepts, or reject more than one option with a clear error at client construction, or keep the current behavior and keep the README caveat. Record the finding in the README section.
  • Add a unit test with an httptest server that checks the exact X-Bz-Test-Mode header lines sent for each single option and for combined options.
  • Add a test that ForceCapExceeded() sends its header on an upload and a download request.
  • Switch from Header.Add to Header.Set if combining is rejected or folded into one value.

Acceptance checks:

  • The header lines sent for each option and for combinations are asserted by tests, not only documented.
  • The README section matches what the live check showed, and the "verify the combination you need" caveat is removed or replaced with the verified behavior.
  • No change to behavior when exactly one option is enabled.

Related: #49, #36.

Lingua principale
Go
Stelle
66
Fork
18
Merge medio
1g 10h
PR unite (30g)
132

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 Backblaze/blazer

Tutte le issue di Backblaze/blazer

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.