Skip to content

[ai] fix(reconciliation): handle FORBIDDEN branchProtectionRule GraphQL error #2069

Description

@github-actions

Caution

Protected files were modified in this change.
This pull request is in request_review mode and requires explicit human scrutiny before merge.

Protected files: .github/workflows/repository-reconciliation.yml

Canonical issue

Fixes a distinct failure signature in the Repository Reconciliation workflow not covered by any open issue/PR. No pre-existing canonical issue was found for this specific crash (checked #2010 and closed reconciliation PRs #1788/#1769/#1825 — none touch branchProtectionRule).

Outcome

Repository Reconciliation (issues trigger) has failed on every recent run with:

GraphqlResponseError: Request failed due to following response errors:
 - Resource not accessible by integration

Root cause: the branch-inventory GraphQL query requests branchProtectionRule { id }, a field the default GITHUB_TOKEN cannot read on this installation. GitHub returns the rest of the page's data alongside a FORBIDDEN partial error for just that field — the script's catch block only recognized rate-limit 403s and re-threw everything else, turning a partial/degraded response into a hard failure (see run 35403628729).

Scope

  • Included:
    • Detect a FORBIDDEN-only GraphQL error and fall back to the partial data.repository.refs payload (protection status treated as unknown) instead of throwing.
    • Regression test mirroring the existing rate-limit-deferral test pattern.
  • Explicitly excluded:
    • No change to branch-deletion behavior, issue/PR classification logic, or permissions.

Risk

  • Risk level: low
  • Failure mode: if GitHub ever changes GraphQL partial-error shape, this falls back to the pre-existing throw err behavior (unchanged from today).
  • Rollback: revert this commit.

Verification

Head: bc769161b

PYTHONPATH=src python -m pytest tests/unit/test_repository_reconciliation_workflow.py -v --no-cov
17 passed
  • Focused tests (17/17 pass, including new regression test)
  • Required CI
  • Review threads resolved

Production evidence

Not applicable: repository automation only; no application or deployment changes. No public URL to verify with Playwright for this workflow-file change.

Evidence chart

Repository Reconciliation run outcomes

Recent issues-triggered runs of this workflow: 4 cancelled (concurrency-superseded) + 1 hard failure (this bug) — none reached completion recently.

Recommended pattern (Chopin / Continuous AI / Autoloop / Agentic Workflows)

Continuous AI is the best fit here: the value delivered was an LLM reading verbose failure logs from a scheduled/event-triggered automation, isolating a partial-API-response edge case, and writing a narrowly-scoped defensive fix with regression coverage — automation supervising automation. This is not a multi-agent planning problem (Chopin), not a simple goal-driven retry loop (Autoloop), and doesn't need new natural-language GitHub Actions authoring (Agentic Workflows).

Agent handoff

  • One canonical issue is linked (opening alongside this PR)
  • No competing PR implements the same fix (confirmed via search)
  • Acceptance criteria are satisfied (tests pass, non-destructive fallback)
  • Required CI passes on the current head
  • Human decision requested only if reviewers want a different fallback strategy

Note

This was originally intended as a pull request, but the git push operation failed.

Original error: The process '/usr/bin/git' failed with exit code 1

Workflow Run: View run details and download bundle artifact

The bundle file is available in the agent artifact in the workflow run linked above.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '35396208196' -n agent -D '/tmp/agent-35396208196'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-35396208196/aw-fix-reconciliation-branch-protection-forbidden.bundle'
temp_ref='refs/bundles/create-pr-pr-iteration-fix-reconciliation-branch-protection-forbidden-a3383ba7'
target_ref='refs/heads/pr-iteration/fix/reconciliation-branch-protection-forbidden'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'pr-iteration/fix/reconciliation-branch-protection-forbidden'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch to the target remote
git push 'origin' 'pr-iteration/fix/reconciliation-branch-protection-forbidden'

# Create the pull request
gh pr create --title '[ai] fix(reconciliation): handle FORBIDDEN branchProtectionRule GraphQL error' --base 'main' --head 'pr-iteration/fix/reconciliation-branch-protection-forbidden' --repo 'groupthinking/EventRelay'

Generated by pr-iteration-loop · copilot · auto · 107.1 AIC · ⌖ 10.1 AIC · ⊞ 11.8K · ◷

  • expires on Sep 25, 2026, 11:07 PM UTC

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions