Skip to content

fix(watch,review): role guard for start_watch_role + 406 diff-too-large fallback#217

Merged
ProtocolWarden merged 2 commits into
mainfrom
oc-watchdog/20260602-0348-role-guard-and-406-fix
Jun 2, 2026
Merged

fix(watch,review): role guard for start_watch_role + 406 diff-too-large fallback#217
ProtocolWarden merged 2 commits into
mainfrom
oc-watchdog/20260602-0348-role-guard-and-406-fix

Conversation

@ProtocolWarden
Copy link
Copy Markdown
Owner

Summary

Two clean fixes cherry-picked onto main (649cf31), rebased from oc-watchdog/20260601-2155-fix-watch-role-guard:

  • fix(watch): reject unknown roles in start_watch_role to prevent crash loopsscripts/operations-center.sh: adds validation guard; unknown roles now emit diagnostic and return 1 instead of restarting every 30s. Root cause: watch-all invoked with role="all", ran crash loop 5+ hours (333+ restart cycles).
  • fix(review): handle HTTP 406 diff-too-large in get_pr_diffgithub_pr.py: falls back to _pr_diff_too_large_summary() using files API when GitHub returns 406. pr_review_watcher/main.py: adds distinct WARNING log for oversized diffs to prevent "empty diff" misclassification.

Custodian

0 findings (confirmed by pre-push hook).

Test plan

🤖 Generated with Claude Code

ProtocolWarden and others added 2 commits June 1, 2026 23:54
… loops

`start_watch_role` had no validation for the role argument; any unknown
role (e.g. "all") fell through to the board_worker.main else-branch with
--role <unknown>, which argparse rejected with exit code 2. The bash
wrapper then restarted the process every 30s indefinitely, producing a
silent crash loop with no operational watcher. Added an explicit guard
that emits a diagnostic and returns 1 immediately. Fixed a live crash
loop (PID 590871, role="all", 333+ cycles, 5+ hours) that prior cycles
misclassified as historical.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…file list

Root cause: GitHub returns 406 when PR diff exceeds the API size limit.
get_pr_diff() silently swallowed HTTPStatusError and returned "", causing
the review watcher to log "empty diff" and skip the PR permanently.

Fix: Detect 406 explicitly in get_pr_diff() and fall back to the files API
(_pr_diff_too_large_summary), returning a file-list summary prefixed with
[DIFF_TOO_LARGE]. The review watcher now logs a distinct warning and
proceeds with the partial diff rather than skipping the PR entirely.

Incidental: ruff-format alignment fixes inherited in both touched files.

Affected repo: OperationsCenter
Gate/check fixed: PR review watcher now processes large-diff PRs (#214)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ProtocolWarden ProtocolWarden merged commit 0e8e4a5 into main Jun 2, 2026
11 of 13 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