fix(yaml-diff): exclude **/*.enc.yaml SOPS files#231
Merged
Conversation
The default exclude_paths includes `**/*.enc.yaml`, but should_exclude() had no branch for the `**/<glob>` shape: a pattern containing `/` but not ending in `/**` fell through to the final `[[ "$path" == "$g" ]]` exact (quoted, non-glob) comparison, which never matched. As a result SOPS- encrypted files were NOT excluded and their diffs were posted as PR comments — the opposite of the documented behaviour. Add a branch that handles `**/<glob>` by matching <glob> against the basename at any depth, so `**/*.enc.yaml` matches `.../secret.enc.yaml`. Verified with a unit test of should_exclude over SOPS / .github / regular paths, and end-to-end against giantswarm/gitops-template#136. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ljakimczuk
approved these changes
Jun 30, 2026
This was referenced Jun 30, 2026
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.
Problem
yaml-diff.yamlships with a defaultexclude_pathsof**/*.enc.yaml .github/** .pre-commit-config.yaml, and the design notes state SOPS files are excluded. They aren't.should_exclude()only handled three pattern shapes:foo/**→ directory prefix*.something(no slash) → basename glob**/*.enc.yamlcontains a/but doesn't end in/**, so it fell into the last branch:[[ "${path}" == "${g}" ]]with${g}quoted, i.e. a literal string compare against**/*.enc.yaml. That never matches a real path, so SOPS-encrypted files were diffed and their contents posted as PR comments — the opposite of the intended/documented behaviour.Confirmed live in giantswarm/gitops-template#136 (a test PR), where the bot posted a diff of
secret.enc.yaml. The production caller in gitops-template uses the defaultexclude_paths, so this affects real PRs.Fix
Add a matcher branch for the
**/<glob>shape that matches<glob>against the basename at any depth, so**/*.enc.yamlmatches.../secret.enc.yaml. The three existing shapes are unchanged and still take precedence (.github/**keeps hitting the/**branch).Also updates the input description and the inline comment to document the shape.
Verification
Unit-tested
should_exclude()over representative paths — all pass:…/mapi/apps/x/secret.enc.yamldeep/nested/foo.enc.yamltop.enc.yaml.github/workflows/ci.yaml.pre-commit-config.yaml…/configmap.yamlsecret.enc.yaml.bakNext: re-point gitops-template#136's caller at this branch to confirm end-to-end that
secret.enc.yamlis no longer diffed.Relates to giantswarm/roadmap#4121.
🤖 Generated with Claude Code