feat(validate): allow declaring ownership of paths that do not exist yet - #12
Open
Elaine-cls wants to merge 1 commit into
Open
feat(validate): allow declaring ownership of paths that do not exist yet#12Elaine-cls wants to merge 1 commit into
Elaine-cls wants to merge 1 commit into
Conversation
Elaine-cls
force-pushed
the
fix/validate-private-groups-and-absent-paths
branch
from
August 26, 2026 16:26
4794a4a to
9d00bd9
Compare
validate required every path named in CODEOWNERS to already exist in the working tree. But declaring an owner ahead of the file is often deliberate and security-relevant: our clearest case is .extension.gitlab-ci.yml, which appears as a rule in 1268 repositories and as a file in almost none. It is executed as a child pipeline from the default branch, so it must already be owned the moment somebody creates it. Neither workaround is acceptable -- creating the file changes pipeline behaviour, since its mere existence triggers that child pipeline, and dropping the rule leaves it unowned. Add --ignore-path / CODEOWNER_IGNORE_PATHS, which opts specific paths out of the existence check; they log a warning instead of an error. Paths that are not listed still fail, so typos keep being reported -- that matters, because it is what surfaces rules naming directories that were never created. verify is untouched, and validate with no new configuration behaves exactly as before.
Elaine-cls
force-pushed
the
fix/validate-private-groups-and-absent-paths
branch
from
August 26, 2026 16:45
9d00bd9 to
c09f52c
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.
validaterequires every path named in CODEOWNERS to already exist in theworking tree. But declaring an owner ahead of the file is often deliberate and
security-relevant.
Our clearest case is
.extension.gitlab-ci.yml: it appears as a rule in 1268 ofour repositories and as a file in almost none. It is executed as a child pipeline
from the default branch, so it must already be owned the moment somebody creates
it. Neither workaround is acceptable — creating the file changes pipeline
behaviour, because its mere existence is what triggers that child pipeline, and
dropping the rule leaves the file unowned.
Fix:
--ignore-path/CODEOWNER_IGNORE_PATHS(comma-separated, repeatable)opts specific paths out of the existence check; they log a warning instead of an
error. Paths that are not listed still fail, so typo detection is preserved —
that matters, because it is exactly what surfaces rules naming directories that
were never created (we have ~1044 repositories in that state).
Compatibility
verifyis untouched.validatewith no new configuration behaves exactly as before.ValidateCodeownerFilegained a parameter; it is library-internal and the onecall site is updated.
Tests
go test ./...passes.TestValidateCodeownerFileIgnorePathscovers four cases:an absent path fails when not opted in; passes once opted in; opting in a
different path does not help; and a single comma-separated value is split and
trimmed (the shape an env var arrives in).
Verified end to end in GitLab CI against a real repository and its real file
tree: the previously failing file reports
Valid CODEOWNERS file, and aninjected bad path still fails.
Not included
An earlier revision of this branch also tried to fix owner resolution for
private groups.
GroupExistsonly consults the globalGET /groups?searchendpoint, which omits private groups the caller is not a member of, so a private
group shared with the project is reported invalid under a CI token.
That attempt fell back to the project's own
shared_with_groups. Testing inreal CI proved this does not work: GitLab filters
shared_with_groupsby thecaller's visibility too. With a project bot token the endpoint returns only the
groups that token can already see:
GET /projects/:id→shared_with_groups/groups?search=<private>['sre', 'sre-team']['sre'][]A project-scoped token fundamentally cannot confirm that a private group it
cannot see exists — no endpoint works around that, because that is what private
means. That half was therefore dropped from this PR rather than shipped inert,
and is being addressed separately on the token/permission side.
Ref: CPER-20260817-04