Skip to content

Guard the Project Link Write So a Refused One Says Something - #1603

Merged
ptr727 merged 2 commits into
developfrom
feature/guard-the-project-link-write
Sep 14, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/guard-the-project-link-write

Conversation

@ptr727

@ptr727 ptr727 commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Answers the finding on #1602, the develop -> main promotion of #1601. A promotion-PR finding needs its own feature cycle, so it lands here first.

apply_project ran its linkProjectV2ToRepository mutation in a bare command substitution. Under the options the script sets, a refused write ended the run with gh'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 gh refuses the mutation pins it. Reverting to the bare substitution, and separately keeping the message while dropping the exit 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

ptr727 and others added 2 commits September 13, 2026 22:06
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]>
Copilot AI lite review requested due to automatic review settings September 14, 2026 05:12
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8615f54d-6bbf-4f9b-bcfb-e4cd571b3808


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.

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.

🟢 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 graphql project-link mutation in apply_project() and emit an operator-actionable failure message before exiting.
  • Extend the project-link test harness to simulate a non-zero gh status 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.

@ptr727
ptr727 merged commit fa73dc7 into develop Sep 14, 2026
9 checks passed
@ptr727
ptr727 deleted the feature/guard-the-project-link-write branch September 14, 2026 13:58
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.

2 participants