Skip to content

fix(ci): propagate-hooks discovery — credential, error honesty, canary, compact JSON - #824

Merged
hyperpolymath merged 2 commits into
mainfrom
fix/807-propagate-hooks-discovery
Sep 17, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
fix/807-propagate-hooks-discovery

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Closes #807.

Re-verified at HEAD 33ec4a7 (2026-09-17) before fixing

  • L95: gh api /repos/$ORG/$REPO_NAME/contents/.githooks | jq -e … — no GH_TOKEN/env: anywhere in the file except L155 (a different step's push credential). Tokenless probe → 2>/dev/null → jq -e reads the error object → every repo "hookless".
  • L106: printf '%s\n' "${REPOS_WITH_HOOKS[@]}" on the empty array → one empty line → jq → [""] → multiline $GITHUB_OUTPUT → Invalid format ' ""'. Defect 2 was the only reason defect 1 was visible.

Fix

Acceptance criterion Implementation
Explicit env: GH_TOKEN + scope in a comment Step-level GH_TOKEN: ${{ secrets.HYPATIA_SCAN_PAT }} — the estate's read-only cross-repo contents credential (same one governance-reusable.yml / allowlist-preflight-reusable.yml use), scope documented in a comment
(implied) serialize honestly Empty array → literal []; non-empty → jq -R . | jq -cs .; also fixed the same latent bug on the target-repo branch (jq -n pretty-prints multiline → would have broken $GITHUB_OUTPUT identically)
No fake green Probe errors are now a third outcome (not folded into hookless): reported per-repo with the API error text, and any error is fatal. Plus a canary: hyperpolymath/standards owns 14 hooks — if it classifies hookless, discovery is broken and the job exits 1 instead of "propagating" nowhere

Validation

  • yaml.safe_load parses; bash -n on the extracted step block passes
  • Logic simulated locally: empty → [], one repo → ["hyperpolymath/standards"], two → ["a/b","c/d"] — all compact single-line
  • Diff: 1 file, +56/−14

…y, compact JSON (closes #807)

The discovery step failed in a way that looked like 'nothing to do':

1. Root cause 1: the .githooks contents probe ran 'gh api' with NO token
   in scope (the file's only token sat on a different step). Tokenless
   calls failed, 2>/dev/null hid the error, and jq -e read the error
   object as 'not an array' — so every repo classified hookless and
   REPOS_WITH_HOOKS was permanently empty.
   → Step now carries env: GH_TOKEN: secrets.HYPATIA_SCAN_PAT, the
     estate's read-only cross-repo PAT (same credential governance and
     allowlist-preflight reusables use for live repo reads), with the
     scope stated in a comment per the issue's acceptance criterion.

2. Root cause 2: printf '%s\n' on an EMPTY bash array prints one empty
   line, so REPOS_JSON became [""], and writing that multiline value to
   $GITHUB_OUTPUT crashed the job ('Invalid format'). An empty list now
   serializes explicitly to [] and all JSON is compact single-line,
   including the target-repo branch (jq -cn).

3. Error-honesty + canary: probe errors are now a third outcome —
   reported and fatal-on-any — and a canary asserts
   hyperpolymath/standards (which owns 14 hooks) always classifies as
   having hooks. Zero-propagation can never fake-green again.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 90cca9bf-8130-4a7d-841b-0a09719fc447

📥 Commits

Reviewing files that changed from the base of the PR and between 176d1f7 and 39fbc72.

📒 Files selected for processing (1)
  • .github/workflows/propagate-hooks.yml

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.

@hyperpolymath
hyperpolymath merged commit cf7d262 into main Sep 17, 2026
17 of 21 checks passed
@hyperpolymath
hyperpolymath deleted the fix/807-propagate-hooks-discovery branch September 17, 2026 20:00
@sonarqubecloud

Copy link
Copy Markdown

# governance-reusable.yml and allowlist-preflight-reusable.yml use
# for live repo reads. Without a token every probe fails silently
# and every repo is misclassified as hookless.
GH_TOKEN: ${{ secrets.HYPATIA_SCAN_PAT }}
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.

propagate-hooks.yml propagates to zero repos: tokenless gh api misclassifies every repo as hookless

2 participants