providers: remove TreatAuthAsTransient, which changed only an error's text (#8299)
release / go (push) Successful in 1m48s
release / web (push) Successful in 1m19s
release / integration (push) Successful in 2m38s
release / govulncheck (push) Successful in 20s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m48s
release / web (push) Successful in 1m19s
release / integration (push) Successful in 2m38s
release / govulncheck (push) Successful in 20s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m57s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
Without the option a 401 or 403 already fell to the default branch, which answers ErrTransient without a retry, the same as the option's own branch. The only difference was "(auth)" in the message. TheAudioDB and both Last.fm providers set it; none read the message. The reason it gave, that a bad key retries later instead of settling the row as "none", now sits on the default branch, and the client's status table checks 401 and 403. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,26 +29,25 @@ func TestHTTPClient_GetJSON_Success(t *testing.T) {
|
||||
}
|
||||
|
||||
// A 404 settles the lookup as not found; any other failure, including a
|
||||
// refused key and a body that isn't JSON, is transient and asked again later.
|
||||
// A 401 is transient with or without TreatAuthAsTransient.
|
||||
// refused key and a body that isn't JSON, is transient and asked again later,
|
||||
// so a bad or expired key never settles a row as having no picture.
|
||||
func TestHTTPClient_GetJSON_AnswersNotFoundOrTransient(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
status int
|
||||
body string
|
||||
authAsRetry bool
|
||||
want error
|
||||
name string
|
||||
status int
|
||||
body string
|
||||
want error
|
||||
}{
|
||||
{"404", http.StatusNotFound, "", false, ErrNotFound},
|
||||
{"401", http.StatusUnauthorized, "", false, ErrTransient},
|
||||
{"401 with TreatAuthAsTransient", http.StatusUnauthorized, "", true, ErrTransient},
|
||||
{"a body that isn't JSON", http.StatusOK, "not json", false, ErrTransient},
|
||||
{"404", http.StatusNotFound, "", ErrNotFound},
|
||||
{"401", http.StatusUnauthorized, "", ErrTransient},
|
||||
{"403", http.StatusForbidden, "", ErrTransient},
|
||||
{"a body that isn't JSON", http.StatusOK, "not json", ErrTransient},
|
||||
} {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(tc.status)
|
||||
_, _ = w.Write([]byte(tc.body))
|
||||
}))
|
||||
c := NewHTTPClient(HTTPOptions{Name: "test", TreatAuthAsTransient: tc.authAsRetry})
|
||||
c := NewHTTPClient(HTTPOptions{Name: "test"})
|
||||
var out struct{ Name string }
|
||||
err := c.GetJSON(context.Background(), srv.URL, &out)
|
||||
srv.Close()
|
||||
|
||||
Reference in New Issue
Block a user