fix(check-catalog-info): stage before diffing so drift is actually detected - #2298
Open
ricky-undeadcoders wants to merge 1 commit into
Open
fix(check-catalog-info): stage before diffing so drift is actually detected#2298ricky-undeadcoders wants to merge 1 commit into
ricky-undeadcoders wants to merge 1 commit into
Conversation
…tected The check ran `make catalog-info.yaml` and then `git diff --staged --exit-code`, but nothing was ever added to the index -- so the diff was always empty and the check passed unconditionally. It has therefore never caught anything. 18 of 39 actions were missing from the catalog entirely, including docker-build-push-image and create-github-app-token, so they did not appear in Backstage at all. Stages first so both new and modified files are seen, and regenerates catalog-info.yaml to clear the accumulated drift. Also normalizes the generator's trailing newline. It emitted a blank line after every document, including the last, which pre-commit's end-of-file-fixer then stripped -- so the generated file differed from the committed one by a single byte and the newly-working check would have failed on every PR.
ricky-undeadcoders
force-pushed
the
rwhitaker/fix-catalog-info-drift-check
branch
from
September 10, 2026 20:57
cca1586 to
216a6a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
check-catalog-info.yamlhas never worked. It runsmake catalog-info.yamland then:--stagedcompares the index against HEAD, and nothing in the job is evergit added — so the diff is always empty and the check passes unconditionally, whatever the generator produced.What that let through
catalog-info.yamlhad drifted by 338 lines. 18 of 39 actions were missing from the catalog entirely , so they never appeared in Backstage:annotate-coverage,azure-trusted-signing,cleanup-branches,component-change-detection,create-github-app-token,docker-build-push-image,docker-export-digest,docker-import-digests-push-manifest,download-branch-workflow-artifact,go-flaky-tests,issues-update-project-status,run-capslock,signed-commits-info,socket-export-sbom,validate-renovate-config,validate-zizmor-config,wait-for-docker-publish,zizmor-collection-pathsThe fix, in two parts
1. Stage before diffing (
.github/workflows/check-catalog-info.yaml):- name: Check for drift run: | + git add -A if ! git diff --staged --exit-code; thengit diffalone would have covered modified files but still missed newly created ones — which is the case that actually mattered here, since a brand-new action has no catalog entry to modify. Also switched the failure to::error::so it surfaces as an annotation rather than a line in the log.2. Normalize the generator's trailing newline (
scripts/generate-catalog-info/main.go).This part is not cosmetic — without it the fixed check fails on every PR.
writeYAMLappends a blank line after each document, which reads well between them but leaves a trailing one at EOF, so the generator emits\n\n. The committed file has a single\n, because pre-commit'send-of-file-fixerhad been quietly stripping the extra one before every commit.That mismatch was invisible while the check was broken. Once the check works, CI regenerates the file, gets
\n\nback, and the diff shows a one-byte change — so it would have gone from never failing to never passing. I hit exactly this in CI on the first push of this PR.Applied at the write site so the
-(stdout) path gets the same treatment.Verification
pre-commit run end-of-file-fixer --files catalog-info.yaml: Passed.make catalog-info.yamlruns: byte-identical.actionlint,gofmt,go vet: clean.Notes
Of the 351 changed lines, 17 are the actual fix — the rest is generated catalog content clearing three months of accumulated drift.
Found while working on #2276, which added an equivalent drift check for action docs. That one already uses
git add -A && git diff --staged --exit-code, and hit the same "generated output must satisfy the formatter" problem with prettier — worth remembering that any generate-and-diff check has both failure modes.Touches no release-please package, so no version bumps.