fix(policy): directory-style path patterns never match in conformance gating#52
Open
MoneyBund wants to merge 4 commits into
Open
fix(policy): directory-style path patterns never match in conformance gating#52MoneyBund wants to merge 4 commits into
MoneyBund wants to merge 4 commits into
Conversation
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.
fix(policy): directory-style path patterns never match in conformance gating
Problem
path_matches()— duplicated across three CI policy scripts — has an unreachablebranch. The pattern is normalized with
pattern.strip("/"), which removes thetrailing slash, so the directory-prefix check below it can never fire:
A directory-style pattern such as
proto/(a natural GitHub-path-filter stylefor the
protocol-paths/conformance-pathsinputs) falls through tofnmatchcase(path, "proto"), which only matches a file literally namedproto. Reproduced:The failure direction is the dangerous one: an SDK repo that configures
protocol-paths: proto/getsprotocol_changed=falsefor every PR touchingproto/, so protocol-sensitive changes silently bypass the conformance gate.The same dead branch makes
select_ci_adapters.pydrop those files fromadapter selection and can make
validate_conformance_pr.pyreject validcoverage PRs.
Fix
Record whether the pattern is directory-style before stripping slashes, and
match on the directory prefix explicitly:
dir/now matches every file underdir/(recursively), does not match afile literally named
dir, and does not over-match sibling directories thatshare the prefix (
src/proto/no longer risks matchingsrc/protocol/…).The
/**and plain-glob branches are unchanged. All three copies were fixedidentically, and the
if not normalized_patternempty-pattern guard that onlycheck_conformance_policy.pyhad is now present in all three.Testing
PathMatchesTesttotest_check_conformance_policy.py, whichexercises all three module copies (directory patterns,
**globs, exactpaths, empty patterns) so the copies cannot silently drift again.
python3 scripts/test_check_conformance_policy.py— 7 tests pass(3 pre-existing subprocess tests + 4 new).