Skip to content

fix(hf-daily-papers): default to yesterday + retry-with-fallback + earlier cron#150

Merged
jeremymanning merged 1 commit into
mainfrom
fix-hf-daily-papers
May 15, 2026
Merged

fix(hf-daily-papers): default to yesterday + retry-with-fallback + earlier cron#150
jeremymanning merged 1 commit into
mainfrom
fix-hf-daily-papers

Conversation

@jeremymanning
Copy link
Copy Markdown
Member

Root cause

The 2026-05-15T00:15Z scheduled run failed with HTTP 400. Analysis:

  • Cron fires at 23:59 UTC, but GitHub Actions queues routinely delay 5-30 min.
  • The actual run started at 00:15:10Z — 16 minutes past midnight UTC.
  • _today_utc() returns the new UTC day (e.g. 2026-05-15) after midnight crossover.
  • HF's daily-papers bucket for that day isn't populated until HF's late-afternoon editorial pipeline runs — https://huggingface.co/api/daily_papers?date=2026-05-15 (queried at 00:16 UTC) returned HTTP 400.
  • The error propagates out as exit code 2 → workflow fails → no papers filed.

Three layered fixes

1. Default to yesterday-UTC

src/llmxive/hf_daily_papers.py _today_utc() now returns (now_utc - 1 day). HF buckets are filled late in the day; yesterday is the safest default.

2. Retry-with-fallback on 400/404

_fetch_daily_json(date, fallback_days=1) now:

  • Tries date first.
  • On HTTP 400 or 404 (bucket not populated), walks back one day and retries.
  • On HTTP 5xx (transient HF issue), propagates unchanged — don't silently swallow real failures.
  • Returns (effective_date, payload) so callers can log when the fallback fired.

fetch_top_papers() updated to return (effective_date, list[Paper]). submit_top_papers() unpacks and logs a fallback message to stderr when triggered.

3. Move cron from 23:59 UTC → 08:00 UTC

.github/workflows/hf-daily-papers.yml schedule: "59 23 * * *""0 8 * * *". At 08:00 UTC, yesterday's bucket is guaranteed-published regardless of any scheduler drift.

Tests

5 new TestDateFallback tests in tests/unit/test_hf_daily_papers.py:

  • test_today_utc_defaults_to_yesterday — _today_utc returns (now - 1 day)
  • test_fetch_falls_back_on_400 — 400 triggers exactly one fallback retry
  • test_fetch_falls_back_on_404 — 404 also triggers fallback
  • test_fetch_does_not_swallow_5xx — 503 propagates unchanged
  • test_fetch_raises_when_all_fallback_attempts_400 — all-400 chain raises the last HTTPError

17/17 HF tests pass (existing 12 + 5 new).

Backward compat

The only API-shape change is fetch_top_papers returning a tuple. All 5 existing test callsites updated to unpack. No external callers exist outside this module + tests.

🤖 Generated with Claude Code

…rlier cron

Root cause (diagnosed from 2026-05-15T00:15Z scheduled-run failure with
HTTP 400):

  - Cron fires at 23:59 UTC but Actions queues routinely delay 5-30
    minutes; the actual run starts past midnight UTC.
  - _today_utc() returns the *new* UTC day after midnight crossover.
  - HF's daily-papers bucket for the new day isn't populated until HF's
    late-afternoon editorial pipeline runs → endpoint returns HTTP 400.

Three layered fixes:

1. **Default to yesterday-UTC** in _today_utc() (src/llmxive/hf_daily_papers.py):
   HF buckets are filled by HF's editorial pipeline late in the day; "today"
   is unreliably-published. Yesterday is guaranteed-complete.

2. **Retry-with-fallback** in _fetch_daily_json(): on HTTP 400/404 for the
   requested date, walk back one day and retry (configurable fallback_days,
   default 1). 5xx and other errors propagate unchanged (transient HF
   problems should not be silently swallowed).

3. **Move cron earlier** in .github/workflows/hf-daily-papers.yml:
   23:59 UTC → 08:00 UTC. 08:00 UTC fetches yesterday's UTC bucket, which
   is guaranteed-published by then regardless of schedule drift.

API change: fetch_top_papers() now returns (effective_date, list[Paper])
instead of just list[Paper] — the effective_date may differ from the
requested date when the fallback chain triggered. submit_top_papers()
unpacks the tuple and logs a fallback message to stderr.

Tests:
- 5 new TestDateFallback tests cover:
  - _today_utc returns yesterday
  - 400 triggers one-day fallback
  - 404 also triggers fallback
  - 5xx propagates unchanged
  - all-400 chain raises the last HTTPError
- All 17 HF tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremymanning jeremymanning merged commit 9c78626 into main May 15, 2026
4 of 5 checks passed
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.

1 participant