Skip to content

fix: re-check FreqBlog 'queued' (202) tracks once within the same run#6

Open
gnujoow wants to merge 1 commit into
mainfrom
fix/issue-2-queued-recheck
Open

fix: re-check FreqBlog 'queued' (202) tracks once within the same run#6
gnujoow wants to merge 1 commit into
mainfrom
fix/issue-2-queued-recheck

Conversation

@gnujoow

@gnujoow gnujoow commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #2.

A 202 from /lookup means an on-demand analysis was just triggered and is usually ready within ~15–60s. Previously a queued track was only retried on the next enrich run (the next day's cron in production), so enriching a playlist interactively left tracks looking failed/pending even though the data was ready seconds later.

Note: bump_enrich_attempt(id, MAX_ATTEMPTS) passes MAX_ATTEMPTS as the limit (not the attempt count), so queued tracks were never immediately terminal — but the practical pain in the issue is real: without an in-run re-check, the drip design makes freshly queued tracks wait a full day per attempt.

Changes

enrich_pending now collects queued tracks and, after the main pass, waits QUEUED_RECHECK_DELAY (30s) and re-looks each up once:

  • ok → stored immediately (no second attempt bump for the same run)
  • rate_limited → stop; remaining tracks stay pending for the next run
  • still queued / not_found → left pending; the next run retries them first (existing attempts DESC ordering), unchanged

The re-check is skipped entirely when the main pass already hit the rate limit. Quota impact is net neutral: each re-check spends the request that the next-run retry would have spent anyway — it just lands the data today instead of tomorrow.

The ok-handling block is extracted into _store_ok() so the main pass and the re-check share it.

Tests

5 new tests (plus an autouse fixture stubbing time.sleep): recovery within the run, single attempt bump when still queued, partial-on-recheck stays pending without an extra bump, re-check skipped after a main-pass 429, and re-check aborting on a 429 mid-pass. Existing queued/MAX_ATTEMPTS drip semantics are unchanged and still covered.

150 passed (baseline 145).

🤖 Generated with Claude Code

A 202 from /lookup means an on-demand analysis was just triggered and is
usually ready within ~15-60s. Previously the track only got retried on
the next enrich run (next day's cron in production), so a playlist
enriched interactively looked 'failed' even though the data was ready
seconds later.

enrich_pending now collects queued tracks and, after the main pass,
waits QUEUED_RECHECK_DELAY (30s) and re-looks them up once:
- ok → stored immediately (no second attempt bump for the same run)
- rate_limited → stop, remaining tracks stay pending for the next run
- still queued / not_found → left pending; next run retries them first
  (attempts DESC ordering) as before

Each re-check spends a request the next-run retry would have spent
anyway, so monthly quota use is net neutral. The re-check is skipped
when the main pass already hit the rate limit.

Fixes #2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enrich: FreqBlog 'queued' (202) responses are misclassified as failed

1 participant