Skip to content

fix(github-backup): drain_queue loads plan/state through the shared validators (#6835) - #7002

Merged
dezren39 merged 1 commit into
mainfrom
queue/11054-6835-drain-validators
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/11054-6835-drain-validators

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6835. Queue task 11054 (lane code-f).

drain_queue.main was the one github-backup consumer still reading plan.json/state.json with bare json.load, bypassing the #6637 shared gates — a single wrong-shape entry (string/int plan entry, dict plan, list state, string/dict drain_last::*, int/string drain_fail::*) crashed every 5-minute drain tick before any event was fetched, acked, or logged.

Change

  • infra/github-backup/bin/drain_queue.py: load state via ghb_common.load_state(root) and plan via ghb_common.load_plan(root), with report_problems — the exact pattern fetch_mirrors/clone_all/manifest already use. Poison entries are named on stderr and skipped/reset; the valid planned repos still drain; state.json is rewritten clean at the end of the run; the DRAIN-CHRONIC path is untouched for genuine repeated failures.

Tests (oracle: the issue's probed crash shapes, driven against the real drain_queue.main)

New cases 20–24 in infra/github-backup/tests/test_drain_queue.py:

  • string/int plan entries named + skipped, valid repo still fetched + acked
  • dict top-level plan → treated as empty, repo drains as unplanned
  • list top-level state → treated as empty, state.json rewritten as a clean object
  • string/dict drain_last::* → dropped, coalesce window not applied, stamp rewritten numeric
  • int/string drain_fail::* → dropped, failure count starts fresh, event stays queued

Full github-backup suite green on the laptop: test_drain_queue 110/110, plus clone_all, deploy, fetch_mirrors, inventory, plan/state shape, and reconcile suites all passing.


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

…alidators (#6835)

drain_queue.main read plan.json/state.json with bare json.load — the one consumer bypassing ghb_common load_plan/load_state (#6637), so a wrong-shape entry crashed every 5-minute drain tick (string/int plan entries, dict plan, list state, string/dict drain_last, int/string drain_fail). Load both through the shared validators with report_problems, exactly like fetch_mirrors/clone_all/manifest: poison entries are named on stderr and skipped/reset, valid repos still drain, state.json is rewritten clean.

Regression tests in test_drain_queue.py cover every probed shape against the real drain_queue.main plus the valid controls; the full github-backup suite is green (test_drain_queue 110/110).
@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 8, 2026 00:49
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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: eea686af-9dea-4ad9-b5a8-a68084307ef3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant