Skip to content

feat(codeowners): Support excluding subdirectories via no-owner rules#115322

Merged
shashjar merged 2 commits into
masterfrom
shashjar/support-excluding-subdirectories-in-codeowners
May 12, 2026
Merged

feat(codeowners): Support excluding subdirectories via no-owner rules#115322
shashjar merged 2 commits into
masterfrom
shashjar/support-excluding-subdirectories-in-codeowners

Conversation

@shashjar
Copy link
Copy Markdown
Member

@shashjar shashjar commented May 11, 2026

Resolves https://linear.app/getsentry/issue/ID-243/codeowners-doesnt-support-excluding-subdirectories.

Follow-up to #115391.

The CODEOWNERS spec (see below) allows for excluding ownership of subdirectories/specified paths by writing a rule with zero owners. With CODEOWNERS synced into Sentry, we are currently ignoring these no-owner rules. This PR implements that exclusion in ownership calculation.

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty. Without an owner, changes
# to `apps/github` can be made with the approval of any user who has
# write access to the repository.
/apps/ @octocat
/apps/github

We will continue to skip lines where owners exist but aren't mapped into Sentry. Our "last match wins" semantics remain.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 11, 2026

ID-243

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 11, 2026
event_tag = ~r"tags.[^:]+"

owners = _ owner+
owners = _ owner*
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or more owners —> zero or more owners

@shashjar shashjar requested a review from a team May 11, 2026 20:41
@shashjar shashjar marked this pull request as ready for review May 11, 2026 20:41
@shashjar shashjar requested review from a team as code owners May 11, 2026 20:41
@shashjar shashjar removed request for a team May 11, 2026 20:42
Comment thread src/sentry/issues/ownership/grammar.py
Copy link
Copy Markdown
Contributor

@cvxluo cvxluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall. 2 questions:

  • will we support this exclusion syntax for issue owners as well?
  • will the frontend handle code owners with no owner properly?

Comment thread tests/sentry/models/test_projectownership.py Outdated
Comment thread tests/sentry/models/test_projectownership.py
@shashjar shashjar marked this pull request as draft May 11, 2026 23:29
@shashjar
Copy link
Copy Markdown
Member Author

  1. Not planning to support this exclusion syntax for issue owners (at least for now). I believe the UI already prevents this, also added some backend validation for this specific to issue owners.

  2. Good catch - I think right now the ownership rules table does not support empty owners. Will make a frontend PR to match.

@shashjar shashjar marked this pull request as ready for review May 12, 2026 18:02
@shashjar shashjar requested a review from cvxluo May 12, 2026 18:02
shashjar added a commit that referenced this pull request May 12, 2026
…115391)

Resolves
https://linear.app/getsentry/issue/ID-243/codeowners-doesnt-support-excluding-subdirectories.

Precursor to #115322.

Displays CODEOWNERS exclusion rules in the ownership rules table, with
the "No Owner" label. Always show exclusion rules regardless of the "My
Teams" owner filter, since they affect all teams.
nikkikapadia pushed a commit that referenced this pull request May 12, 2026
…115391)

Resolves
https://linear.app/getsentry/issue/ID-243/codeowners-doesnt-support-excluding-subdirectories.

Precursor to #115322.

Displays CODEOWNERS exclusion rules in the ownership rules table, with
the "No Owner" label. Always show exclusion rules regardless of the "My
Teams" owner filter, since they affect all teams.
@shashjar shashjar merged commit 1428bcb into master May 12, 2026
69 checks passed
@shashjar shashjar deleted the shashjar/support-excluding-subdirectories-in-codeowners branch May 12, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants