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 21adbc2283.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 15:30:55 -05:00
co-authored by Claude Opus 5.5
parent 21adbc2283
commit da21becead
10 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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")
}
}
+1 -1
View File
@@ -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{
+1 -1
View File
@@ -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},
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}
}
+1 -1
View File
@@ -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
}