Repository navigation
Guard the Project Link Write So a Refused One Says Something - #1603
Conversation
The mutation ran in a bare command substitution, so a refused write ended the run with gh's own error and nothing of this script's: no repository, no project, and no scope to grant. The pre-flight's resolution does not catch it, since that one is a read and this is the write, so a token holding project read alone reaches the link with the four earlier groups applied and learns none of that from the output. The call is guarded now and names the repository, the project, and the scope. A harness whose gh refuses the mutation pins it, and removing the guard fails the suite. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The comment said a token that reads projects and cannot write a link is the failure that reaches the guard, where it is the one the guard was written for and every other non-zero exit lands there too, a rate limit, a network failure, and the project being deleted between the pre-flight resolution and this write among them. The operator-facing message already hedged; the comment did not, so a reader diagnosing a 502 was told by the file that the cause is a scope problem. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, preserves existing control flow on success, and is covered by a new targeted regression test for the refused-write behavior.
Pull request overview
This PR improves operational diagnosability of repo-config/configure.sh apply by guarding the linkProjectV2ToRepository GraphQL mutation so that a refused write produces a clear, actionable script error (repo + project + scope hint) instead of terminating with only gh's error output.
Changes:
- Guard the
gh api graphqlproject-link mutation inapply_project()and emit an operator-actionable failure message before exiting. - Extend the project-link test harness to simulate a non-zero
ghstatus and assert the new stderr message is produced.
File summaries
| File | Description |
|---|---|
| scripts/tests/test_configure_project.py | Adds a refused-write test case and extends the helper to drive gh exit status through the stub. |
| repo-config/configure.sh | Wraps the project-link mutation in an explicit failure guard that prints a script-owned error message and exits non-zero. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Answers the finding on #1602, the
develop -> mainpromotion of #1601. A promotion-PR finding needs its own feature cycle, so it lands here first.apply_projectran itslinkProjectV2ToRepositorymutation in a bare command substitution. Under the options the script sets, a refused write ended the run withgh's own error and nothing of the script's: no repository, no project, and no scope to grant. The pre-flight's resolution does not catch that one, because the pre-flight is a read and this is the write, so a token holding project read alone reaches the link with the four earlier write groups already applied and learns none of that from the output.The call is guarded now and names the repository, the project, and the scope, hedged with "may" since every other non-zero exit lands in the same arm: a rate limit, a network failure, or the project being deleted between the pre-flight and this write.
A harness whose
ghrefuses the mutation pins it. Reverting to the bare substitution, and separately keeping the message while dropping theexit 1, each fail the suite.Verification
Two local review passes, the second finding only that the guard's comment named one cause as the cause, which the second commit narrows. Gates run locally: shellcheck, shfmt, ruff check and format, mypy, 1465 tests, the prose gate, the repo gate,
spec/validate.py, and the seven Docker linters.🤖 Generated with Claude Code
https://claude.ai/code/session_01AYoF5QrrkhEWt7F7G8RDvB