From da21beceadae5d8fffdc39ecffd8daf1008c7886 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 2 Dec 2026 15:30:55 -0500 Subject: [PATCH] Revert the deliberate break (#8299) Run 11302 failed all ten named tests, and with them apierror's TestWrite_SendsTheEnvelopeAndHidesAPlainErrorsText and api's TestFlag_BadReason, which pin the same rules from the handler side. This reverts commit 21adbc22835220b0a607a5c90163ac58accd8501. Co-Authored-By: Claude Opus 5.5 --- internal/apierror/apierror.go | 2 +- internal/auth/admin.go | 2 +- internal/backup/tables.go | 2 +- internal/playevents/writer.go | 2 +- internal/playsessions/service.go | 2 +- internal/providers/httpclient.go | 2 +- internal/quarantine/service.go | 2 +- internal/recsettings/patch.go | 2 +- internal/scrobble/listenbrainz/client.go | 2 +- internal/scrobble/threshold.go | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/apierror/apierror.go b/internal/apierror/apierror.go index f9fde568..9a01b7e1 100644 --- a/internal/apierror/apierror.go +++ b/internal/apierror/apierror.go @@ -33,7 +33,7 @@ func From(err error) *Error { if errors.As(err, &apiErr) { return apiErr } - return BadRequest("bad", err.Error()) /* DELIBERATE BREAK */ + return Internal(err) } func NotFound(what string) *Error { diff --git a/internal/auth/admin.go b/internal/auth/admin.go index a2ea165b..16dfdcda 100644 --- a/internal/auth/admin.go +++ b/internal/auth/admin.go @@ -22,7 +22,7 @@ func RequireAdmin() func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { user, ok := UserFromContext(r.Context()) - if !ok && false /* DELIBERATE BREAK */ { + if !ok { // Programmer error: RequireUser was not mounted before RequireAdmin. apierror.Write(w, apierror.InternalMsg("admin check mounted without a user", nil)) return diff --git a/internal/backup/tables.go b/internal/backup/tables.go index 30e12d38..608cd706 100644 --- a/internal/backup/tables.go +++ b/internal/backup/tables.go @@ -171,7 +171,7 @@ func Coverage(schema []string) []string { problems = append(problems, t.Name+": listed twice in Tables") } seen[t.Name] = true - if !inSchema[t.Name] && false /* DELIBERATE BREAK */ { + if !inSchema[t.Name] { problems = append(problems, t.Name+": in Tables but not in the schema") } } diff --git a/internal/playevents/writer.go b/internal/playevents/writer.go index 709f4110..3882362e 100644 --- a/internal/playevents/writer.go +++ b/internal/playevents/writer.go @@ -231,7 +231,7 @@ func (w *Writer) RecordPlayEnded( if track.DurationMs > 0 { ratio = float64(durationPlayedMs) / float64(track.DurationMs) } - isSkip := ratio < w.skipMaxCompletionRatio || /* DELIBERATE BREAK */ durationPlayedMs < w.skipMaxDurationPlayedMs + isSkip := ratio < w.skipMaxCompletionRatio && durationPlayedMs < w.skipMaxDurationPlayedMs ratioPtr := ratio durPtr := durationPlayedMs if _, err := q.UpdatePlayEventEnded(ctx, dbq.UpdatePlayEventEndedParams{ diff --git a/internal/playsessions/service.go b/internal/playsessions/service.go index 1415b916..d09e5467 100644 --- a/internal/playsessions/service.go +++ b/internal/playsessions/service.go @@ -37,7 +37,7 @@ func FindOrCreate( // "Within window" includes the exact-boundary case: gap <= timeout // extends. gap := eventTime.Sub(prev.LastEventAt.Time) - if gap < timeout /* DELIBERATE BREAK */ { + if gap <= timeout { if err := q.TouchPlaySessionLastEvent(ctx, dbq.TouchPlaySessionLastEventParams{ ID: prev.ID, LastEventAt: pgtype.Timestamptz{Time: eventTime, Valid: true}, diff --git a/internal/providers/httpclient.go b/internal/providers/httpclient.go index df24f6a9..32c17538 100644 --- a/internal/providers/httpclient.go +++ b/internal/providers/httpclient.go @@ -190,7 +190,7 @@ func (c *HTTPClient) attempt(ctx context.Context, fullURL, accept string, attemp return resp, false, nil case resp.StatusCode == http.StatusNotFound: _ = resp.Body.Close() - return nil, false, ErrTransient /* DELIBERATE BREAK */ + return nil, false, ErrNotFound case c.opts.TreatAuthAsTransient && (resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden): _ = resp.Body.Close() diff --git a/internal/quarantine/service.go b/internal/quarantine/service.go index 0c1bfd85..2c7af35e 100644 --- a/internal/quarantine/service.go +++ b/internal/quarantine/service.go @@ -42,7 +42,7 @@ func NewService(pool *pgxpool.Pool, dataDir string) *Service { // Flag inserts or updates a quarantine row for the caller. Re-flagging // the same (user, track) overwrites reason+notes (and bumps created_at). func (s *Service) Flag(ctx context.Context, userID, trackID pgtype.UUID, reason string, notes string) (dbq.Quarantine, error) { - if !validReason(reason) && false /* DELIBERATE BREAK */ { + if !validReason(reason) { return dbq.Quarantine{}, ErrBadReason } var notesPtr *string diff --git a/internal/recsettings/patch.go b/internal/recsettings/patch.go index 9eddc384..9bd90eeb 100644 --- a/internal/recsettings/patch.go +++ b/internal/recsettings/patch.go @@ -142,7 +142,7 @@ func applyTastePatch(current TasteTuning, patch map[string]float64) (TasteTuning default: return current, nil, fmt.Errorf("%w: %q", ErrUnknownField, field) } - if field != "half_life_days" && (v < 0 || v > 100) /* DELIBERATE BREAK */ { + if field != "half_life_days" && (v < 0 || v > 1) { return current, nil, fmt.Errorf("%w: %s = %v (must be in [0, 1])", ErrOutOfRange, field, v) } diff --git a/internal/scrobble/listenbrainz/client.go b/internal/scrobble/listenbrainz/client.go index dc4ead3a..28cfce5a 100644 --- a/internal/scrobble/listenbrainz/client.go +++ b/internal/scrobble/listenbrainz/client.go @@ -124,7 +124,7 @@ func (c *Client) SubmitListens(ctx context.Context, token string, listens []List case resp.StatusCode >= 500: return fmt.Errorf("%w: status %d", ErrTransient, resp.StatusCode) default: - return fmt.Errorf("%w: status %d", ErrTransient, resp.StatusCode) /* DELIBERATE BREAK */ + return fmt.Errorf("%w: status %d", ErrPermanent, resp.StatusCode) } } diff --git a/internal/scrobble/threshold.go b/internal/scrobble/threshold.go index 7db1d7d8..1b564057 100644 --- a/internal/scrobble/threshold.go +++ b/internal/scrobble/threshold.go @@ -10,5 +10,5 @@ package scrobble // The two thresholds are deliberately separate from the skip-detection // thresholds, which feed the scoring formula's skip penalty instead. func Qualifies(durationPlayedMs int, completionRatio float64) bool { - return durationPlayedMs > 240_000 /* DELIBERATE BREAK */ || completionRatio >= 0.5 + return durationPlayedMs >= 240_000 || completionRatio >= 0.5 }