Skip to content

Fix grumpy-reviewer checkout (PR-branch fetch fails: not a git repository) - #16617

Merged
bodhish merged 1 commit into
developfrom
grumpy-reviewer-checkout-fix
Jul 31, 2026
Merged

Fix grumpy-reviewer checkout (PR-branch fetch fails: not a git repository)#16617
bodhish merged 1 commit into
developfrom
grumpy-reviewer-checkout-fix

Conversation

@amjithtitus09

@amjithtitus09 amjithtitus09 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Problem

The grumpy-reviewer agentic workflow added in #16616 is failing on every PR it triggers on. Example runs on develop: #16612, #16610, #16579 — all fail at the Checkout PR branch step with:

🔄 Checkout Strategy: git fetch refs/pull + checkout
fatal: not a git repository (or any of the parent directories): .git
Event type: pull_request_target
Error message: The process '/usr/bin/git' failed with exit code 128

This is not a token problem — the activation job (which validates COPILOT_GITHUB_TOKEN) passes in ~19s. The failure is in the agent job.

Cause

#16616 shipped the workflow with checkout: false. That was based on the assumption that the agent reads everything through the GitHub API. But the imported grumpy-reviewer agent uses local-file tools (read/search), so gh-aw injects a Checkout PR branch step that runs git fetch origin +refs/pull/N/head. With checkout: false there is no base actions/checkout, so there is no .git directory and the fetch aborts with exit 128.

Fix

Remove checkout: false from .github/workflows/grumpy-reviewer.md and recompile. The compiled agent job now runs the base Checkout repository (actions/checkout, persist-credentials: false) before the injected Checkout PR branch fetch, so the PR head is fetched into a valid git repo.

Two files change: the source .md (4 lines removed) and the generated .lock.yml (gh aw compile, v0.80.9).

Security note

Enabling checkout under pull_request_target brings back the compiler's advisory "pwn request" warning. It's acceptable here: the agent job is read-only (permissions: read-all), never executes untrusted PR code (only reads files + calls the GitHub MCP / Copilot inference in gh-aw's firewalled sandbox), and every write is confined to the separate permission-scoped safe-output jobs.

Testing

Verified end-to-end with gh aw trial (simulating github.repository = ohcnetwork/care_fe, real PR trigger context). The full run is green: activation ✓ → agent ✓ (2m26s)detection ✓ → safe_outputs ✓. The agent checked out the PR, reviewed the changed lines, and produced grumpy-but-constructive inline review comments plus a consolidated COMMENT review (captured as safe-outputs, not posted to any real PR).

Compile: 0 errors, 1 advisory warning (the pwn note above). No app build/test run — workflow config only.

Summary by CodeRabbit

  • Chores
    • Updated automated review workflow configuration.
    • Improved repository access and credential handling during automated checks.
    • Enabled the workflow to check out repository contents when needed.

The grumpy-reviewer workflow shipped in #16616 set `checkout: false`, but the
imported agent uses local-file tools (read/search), so gh-aw injects a
"Checkout PR branch" step (git fetch +refs/pull/N/head). With no base checkout
there is no .git, so that step fails on every PR:

    fatal: not a git repository (or any of the parent directories): .git
    The process '/usr/bin/git' failed with exit code 128

Removing `checkout: false` restores the base actions/checkout (persist-credentials:
false) before the PR-branch fetch. Verified end-to-end via `gh aw trial`
(agent job succeeds, grumpy inline review comments produced).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

⚠️ Merge Checklist Incomplete

Thank you for your contribution! To help us review your PR efficiently, please complete the merge checklist in your PR description.

Your PR will be reviewed once you have marked the appropriate checklist items.

To update the checklist:

  • Change - [ ] to - [x] for completed items
  • Only check items that are relevant to your PR
  • Leave items unchecked if they don't apply

The checklist helps ensure code quality, testing coverage, and documentation are properly addressed.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: e1cdc46
Status: ✅  Deploy successful!
Preview URL: https://64acfe99.care-preview-a7w.pages.dev
Branch Preview URL: https://grumpy-reviewer-checkout-fix.care-preview-a7w.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5edf236c-7adf-4c62-99da-91e57d9e2668

📥 Commits

Reviewing files that changed from the base of the PR and between cb27e0e and e1cdc46.

📒 Files selected for processing (2)
  • .github/workflows/grumpy-reviewer.lock.yml
  • .github/workflows/grumpy-reviewer.md
💤 Files with no reviewable changes (1)
  • .github/workflows/grumpy-reviewer.md

Walkthrough

Changes

Grumpy Reviewer workflow

Layer / File(s) Summary
Enable repository checkout
.github/workflows/grumpy-reviewer.md, .github/workflows/grumpy-reviewer.lock.yml
The workflow removes the disabled-checkout setting and adds repository checkout with persisted credentials disabled.
Configure Git credentials
.github/workflows/grumpy-reviewer.lock.yml
The workflow configures Git credentials before and after agent execution and updates the generated metadata hash.

Possibly related PRs

Suggested reviewers: jacobjeevan, bodhish, gigincg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the problem, cause, fix, security impact, and testing results, but it does not use the template headings or include the merge checklist.
Title check ✅ Passed The title clearly identifies the grumpy-reviewer checkout failure and the required fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch grumpy-reviewer-checkout-fix

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ⏭️ Skipped

No test-related files were changed in this PR.

Tests are skipped when changes don't affect:

  • tests/**
  • src/**
  • package.json
  • playwright.config.ts

Run: #10554

@bodhish
bodhish merged commit dea4985 into develop Jul 31, 2026
39 of 43 checks passed
@bodhish
bodhish deleted the grumpy-reviewer-checkout-fix branch July 31, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the failing grumpy-reviewer agentic workflow by ensuring the agent job runs inside a valid git repository before gh-aw’s injected “Checkout PR branch” fetch step.

Changes:

  • Removed checkout: false from the workflow source so the compiled workflow performs a base actions/checkout first.
  • Regenerated the compiled workflow (.lock.yml), which now includes “Checkout repository” (with persist-credentials: false) before “Checkout PR branch”.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/grumpy-reviewer.md Removes the checkout: false override so checkout is enabled (default), allowing PR-branch fetch to succeed.
.github/workflows/grumpy-reviewer.lock.yml Compiled output updated to include base checkout + git credential configuration prior to PR-branch checkout.

Comment on lines 33 to 36
# Actions GITHUB_TOKEN, and gh-aw injects the needed write scopes into the
# separate safe-output jobs while this agent job stays read-only.
permissions: read-all
# No local clone is needed: the agent reads the PR diff and changed files through
# the GitHub API. Disabling checkout removes the "pwn request" attack surface that
# comes from checking out untrusted fork code under pull_request_target.
checkout: false
imports:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants