Skip to content

On GitHub Free, org secrets do not reach private repositories - #18

Merged
brettheap merged 1 commit into
mainfrom
docs/free-plan-repo-secrets
Sep 4, 2026
Merged

brettheap merged 1 commit into
mainfrom
docs/free-plan-repo-secrets

Conversation

@brettheap

@brettheap brettheap commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Lane: repo-shape

The failure is silent and the check goes green. GitHub delivers an ORGANISATION Actions secret only to PUBLIC repositories on the Free plan. Every repository this standard creates is private by default, so secrets.SHAPE_LEGS_APP_ID resolves to the empty string inside the workflow — no error, no warning — the App-token steps skip, the legs go unfetched, and validate reports success with the lockstep pin check degraded away. Somebody who configured everything correctly gets a green required check that verified nothing.

Measured, not hypothesised

InkRouter, 2026-09-04, the second organisation to adopt: the openreposhape App was installed on all repositories and both org secrets existed at visibility: all, and both split pull requests still ran leg credential source: none and fetched no legs. MedxSoft is on Enterprise, which is why the identical configuration works there and the difference went unnoticed until an org on Free tried it.

The exits are repository secrets — which are delivered to private repositories on every plan — or a Team upgrade.

What this adds

scripts/repo_shape.py gains free_plan_secret_hint(), called by all three tools that create a private repository: scaffold-project.py, adopt-project.py execute, family.py init. It reads gh api orgs/<org> --jq .plan.name and prints only on a confident free.

Every other answer is silent — no gh on PATH, a failed call, an empty or unparseable response, a paid plan. Offline and local-remote modes print nothing rather than guess: a wrong hint about credentials is worse than none.

Documented in the README and both the assembly-root and family-root template READMEs. The tool hint reaches whoever ran the tool; the READMEs reach whoever inherits the repository afterwards.

Tests

tests/test_free_plan_hint.py stubs gh as a shell script on PATH and pins the hint in both directions: present on free (including "Free " — the answer is stripped and casefolded), absent on team/enterprise/business, a failed call, an empty answer, and no gh at all. Plus that all three creating tools call it with their own org, and all three documents carry the note.

Full suite green: 344 passed. The README section is written to four lines because test_readme_is_short_enough_to_be_read caps the file at 508 and that cap is the point — it now sits exactly at 508.

Not for merge

Opened for review only, per the instruction that produced it.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

Summary by Sourcery

Warn users when GitHub Free prevents organization secrets from reaching private repositories so credential configuration does not silently degrade validation.

New Features:

  • Add a Free-plan diagnostic that directs users to repository secrets when private repositories cannot receive organization Actions secrets.

Bug Fixes:

  • Prevent silent green validation checks from appearing successful when leg credentials are unavailable on GitHub Free.

Enhancements:

  • Invoke the diagnostic when scaffold, adoption, and family initialization create repositories.
  • Document GitHub Free secret limitations and repository-secret configuration in the main and generated repository READMEs.

Documentation:

  • Explain the GitHub Free organization-secret limitation and recommended repository-secret setup in project and template READMEs.

Tests:

  • Add coverage for Free-plan detection, non-Free and unavailable API responses, all repository-creating tools, and the accompanying documentation.

THE FAILURE IS SILENT AND THE CHECK GOES GREEN, which is the worst way for
this to be wrong. GitHub delivers an ORGANISATION Actions secret only to
PUBLIC repositories on the Free plan. Every repository this standard creates
is private by default, so `secrets.SHAPE_LEGS_APP_ID` resolves to the empty
string inside the workflow — no error, no warning — the App-token steps skip,
the legs go unfetched, and `validate` reports SUCCESS with the lockstep pin
check degraded away. Somebody who configured everything correctly gets a green
required check that verified nothing.

Measured on InkRouter, 2026-09-04, the second organisation to adopt: the
`openreposhape` App was installed on all repositories and both org secrets
existed at `visibility: all`, and both split pull requests still ran
`leg credential source: none` and fetched no legs. MedxSoft is on Enterprise,
which is why the identical configuration works there and the difference went
unnoticed until an org on Free tried it. The fix is repository secrets, which
ARE delivered to private repositories on every plan, or a Team upgrade.

`scripts/repo_shape.py` gains `free_plan_secret_hint()`, called by all three
tools that create a private repository — `scaffold-project.py`,
`adopt-project.py execute` and `family.py init`. It reads
`gh api orgs/<org> --jq .plan.name` and prints the hint only on a confident
`free`. Every other answer is silent: no `gh` on PATH, a failed call, an empty
or unparseable response, a paid plan. Offline and local-remote modes therefore
print nothing rather than guess, because a wrong hint about credentials is
worse than none.

Documented in the README and in the assembly-root and family-root template
READMEs — the tool hint reaches whoever ran the tool, the READMEs reach
whoever inherits the repository afterwards. The README section is written to
four lines because `test_readme_is_short_enough_to_be_read` caps the file at
508 and that cap is the point; it now sits exactly at 508.

`tests/test_free_plan_hint.py` stubs `gh` as a shell script on PATH and pins
the hint in BOTH directions — it appears on `free` (including `"Free "`, since
the answer is stripped and casefolded) and stays silent on team, enterprise,
business, a failed call, an empty answer and no `gh` at all — plus that all
three creating tools call it with their own org and all three documents say
it. Full suite green: 344 passed.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Copilot AI lite review requested due to automatic review settings September 4, 2026 04:10
@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR adds a fail-safe GitHub Free-plan check that warns creators when organization Actions secrets will not reach their private repositories, integrates it into all private-repository creation paths, documents the repository-secret workaround, and adds focused coverage for detection, silence-on-uncertainty, integration, and documentation.

Sequence diagram for Free-plan secret hint during repository creation

sequenceDiagram
    participant Creator
    participant Tool as scaffold/adopt/family
    participant Hint as free_plan_secret_hint
    participant GH as GitHub CLI

    Creator->>Tool: Create private repository
    Tool->>Hint: free_plan_secret_hint(org, repo, what)
    Hint->>GH: gh api orgs/{org} --jq .plan.name
    alt plan is free
        GH-->>Hint: Free
        Hint-->>Tool: Repository-secret warning
        Tool-->>Creator: Print warning
    else non-free, failed, empty, or gh unavailable
        GH-->>Hint: No confident free result
        Hint-->>Tool: None
        Tool-->>Creator: Continue silently
    end
Loading

Flow diagram for Free-plan Actions secret failure and workaround

flowchart LR
    A[Org Actions secrets] --> B{GitHub Free plan?}
    B -->|Private repository| C[Secrets resolve to empty]
    C --> D[App steps skip]
    D --> E[Legs are not fetched]
    E --> F[validate passes with pin check skipped]
    B -->|Use repository secrets| G[Secrets reach private repository]
    B -->|Upgrade to Team| G
    G --> H[validate can check the lockstep pins]
Loading

File-Level Changes

Change Details Files
Add a conservative Free-plan detection helper that explains why organization secrets fail for private repositories and recommends repository secrets.
  • Query the organization plan through gh api.
  • Return the hint only for a successful, normalized free-plan response.
  • Remain silent when gh is unavailable, the request fails, or the response is not confidently Free.
  • Include repository-specific secret commands and explain the silent validation degradation.
scripts/repo_shape.py
Surface the Free-plan credential guidance whenever a tool creates private repositories.
  • Invoke the helper from scaffold, adopt, and family initialization flows.
  • Pass each flow’s organization, repository, and contextual repository description.
  • Print nothing when plan detection produces no hint.
scaffold-project.py
adopt-project.py
scripts/family.py
Document the repository-secret requirement and silent validation failure in user-facing guidance.
  • Add concise guidance to the main README.
  • Add equivalent notes to assembly-root and family-root template READMEs.
  • Explain repository-secret commands and the Team upgrade alternative.
README.md
templates/assembly-root/README.md
templates/family-root/README.md
Test both positive and negative plan-detection behavior and verify integration and documentation coverage.
  • Stub gh on PATH to test Free, whitespace-normalized Free, paid plans, failures, empty output, and missing gh.
  • Verify all three repository-creating tools call the helper with their organization.
  • Verify all three documentation files contain the Free-plan and repository-secret guidance.
tests/test_free_plan_hint.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/repo_shape.py" line_range="592-594" />
<code_context>
+    rather than guess — a wrong hint about credentials is worse than none.
+    """
+    try:
+        proc = subprocess.run(
+            ["gh", "api", f"orgs/{org}", "--jq", ".plan.name"],
+            capture_output=True, text=True, check=False)
+    except (FileNotFoundError, OSError):
+        return None
</code_context>
<issue_to_address>
**issue (bug_risk):** `free_plan_secret_hint` performs a network-backed `gh api` call without a timeout, so an authenticated but unreachable or stalled GitHub endpoint blocks the repository-creation command indefinitely instead of returning silently as documented.

**Triggers:** When `gh` is installed and the network connection or GitHub API request hangs after repository creation.

**Suggested fix:** Pass a finite `timeout` to `subprocess.run` and catch `subprocess.TimeoutExpired` alongside the existing launch errors.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: scripts/repo_shape.py:594


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread scripts/repo_shape.py
Comment on lines +592 to +594
proc = subprocess.run(
["gh", "api", f"orgs/{org}", "--jq", ".plan.name"],
capture_output=True, text=True, check=False)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): free_plan_secret_hint performs a network-backed gh api call without a timeout, so an authenticated but unreachable or stalled GitHub endpoint blocks the repository-creation command indefinitely instead of returning silently as documented.

Triggers: When gh is installed and the network connection or GitHub API request hangs after repository creation.

Suggested fix: Pass a finite timeout to subprocess.run and catch subprocess.TimeoutExpired alongside the existing launch errors.

@brettheap
brettheap merged commit 94978f8 into main Sep 4, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

There are a few concrete reliability/clarity issues (best-effort gh api call can hang without a timeout; hint wording/subject mismatch; brittle source-formatting assertion) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a best-effort diagnostic to prevent a silent/green validation degradation on GitHub Free orgs where organization Actions secrets are not delivered to private repositories, and documents the required workaround (repository secrets) in the generated READMEs.

Changes:

  • Add free_plan_secret_hint() in scripts/repo_shape.py and call it from the repo-creating entrypoints (scaffold/adopt/family init).
  • Document the GitHub Free org-secret limitation and the --repo-scoped secret setup in the main README and both templates.
  • Add a new test module to pin the hint’s behavior and ensure all creator tools and docs include the note.
File summaries
File Description
scripts/repo_shape.py Adds the Free-plan detection and hint text emitted at repository creation time.
scaffold-project.py Calls the hint when creating private/internal repositories.
adopt-project.py Calls the hint when adoption creates private/internal repositories.
scripts/family.py Calls the hint when initializing a private/internal family holder.
README.md Documents the Free-plan org-secret limitation and repo-secret workaround.
templates/assembly-root/README.md Carries the same guidance into generated assembly roots.
templates/family-root/README.md Carries the same guidance into generated family roots.
tests/test_free_plan_hint.py Adds coverage for Free-plan detection behavior, tool integration, and doc presence.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread adopt-project.py
Comment on lines +996 to +998
hint = free_plan_secret_hint(
plan.get("org", ""), repositories["assembly"],
f"{repositories['spec']} and {repositories['code']} are")
Comment thread scaffold-project.py
Comment on lines +615 to +617
hint = free_plan_secret_hint(
args.org, repositories["assembly"],
f"{repositories['spec']} and {repositories['code']} are")
Comment thread scripts/repo_shape.py
Comment on lines +591 to +600
try:
proc = subprocess.run(
["gh", "api", f"orgs/{org}", "--jq", ".plan.name"],
capture_output=True, text=True, check=False)
except (FileNotFoundError, OSError):
return None
if proc.returncode != 0:
return None
if proc.stdout.strip().lower() != "free":
return None
Comment on lines +108 to +111
source = (REPO / tool).read_text()
assert "free_plan_secret_hint" in source, f"{tool} does not import it"
assert f"free_plan_secret_hint(\n {call}" in source, \
f"{tool} does not call it with its own org"
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