Skip to content

fix(github-backup): validate last_fetch shape in validate_state (#6821) - #8686

Merged
dezren39 merged 2 commits into
mainfrom
queue/11045-6821-last-fetch-shape
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/11045-6821-last-fetch-shape

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #6821.

Problem

validate_state (#6637) checked per-repo entry shape, fail_days, and the drain_* bookkeeping keys, but not the per-repo last_fetch field — the one field fetch_mirrors.main does arithmetic on at the coalesce check. A string/list/dict last_fetch (hand edit, older/newer writer, torn write per #3240) passed validation silently and raised TypeError inside the repo loop, so no repo was fetched, state.json was never rewritten, and MANIFEST regeneration never ran. A bool last_fetch silently read as epoch 1.

Fix

ghb_common.validate_state: a per-repo last_fetch that is present and not an int/float (bools excluded, matching the drain_last:: rule) is dropped under a named problem, visible via report_problems. The repo is then treated as never-fetched and fetched normally. Drain bookkeeping entries (drain_*) keep their own shapes and are not last_fetch-validated — their inner fields are preserved verbatim. Numeric behavior is unchanged exactly: fresh entries coalesce-skip (<12h), stale entries fetch.

Tests

Oracle: the #6821 acceptance criteria — a wrong-shape last_fetch produces a named problem and never reaches the fetch loop as a non-number; the full loop completes.

  • test_plan_state_shape.py: string/list/dict/bool shapes named + dropped, numeric control (int/float/0) passes unchanged, drain_fail inner fields preserved; the property-test state oracle now encodes the same invariant.
  • test_fetch_mirrors.py: full-loop test — poisoned repo fetched, fresh repo coalesce-skips, state.json rewritten with numeric last_fetch, manifest build called once, problem named on stderr.
  • Whole infra/github-backup/tests/ suite green (all 13 files).

Queue task 11045, lane code-c.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A wrong-shape per-repo last_fetch (string/list/dict/bool) passed #6637 validation and crashed fetch_mirrors.main at the coalesce check, wedging the whole daily fetch. validate_state now drops a non-numeric last_fetch under a named problem (drain bookkeeping entries keep their own shapes), so the repo is fetched normally and the loop, state rewrite, and manifest regeneration all complete. Regression tests: unit shapes + numeric control in test_plan_state_shape.py (property oracle updated), full-loop test in test_fetch_mirrors.py. Full github-backup suite green.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 13:49
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d335f483-be80-43e3-b7db-8251082e0bae
Commits

Reviewing files that changed from the base of the PR and between 07c2b18 and 147ebe2.

Files selected for processing: 3

  • infra/github-backup/bin/ghb_common.py
  • infra/github-backup/tests/test_fetch_mirrors.py
  • infra/github-backup/tests/test_plan_state_shape.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T14:16:03.908669Z 147ebe2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

New PR for #6821: validate_state drops a wrong-shape per-repo last_fetch under a named problem so fetch_mirrors.main cannot crash at the coalesce check. Please review head e3f954a. (Queue worker lane code-c, task 11045.)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e3f954ae15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39 dezren39 added queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition work/assigned Queue worker lifecycle state labels Nov 11, 2026
@dezren39
dezren39 merged commit 5197d73 into main Nov 11, 2026
1 of 9 checks passed
@dezren39
dezren39 deleted the queue/11045-6821-last-fetch-shape branch November 11, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition work/assigned Queue worker lifecycle state

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github-backup(fetch): a wrong-shape last_fetch field passes #6637 validation and crashes the whole daily fetch

1 participant