Skip to content

ref(repositories): Remove feature flag branching for SeerProjectRepository reads#115606

Open
wedamija wants to merge 3 commits into
masterfrom
danf/repo-remove-seer-proj-branch
Open

ref(repositories): Remove feature flag branching for SeerProjectRepository reads#115606
wedamija wants to merge 3 commits into
masterfrom
danf/repo-remove-seer-proj-branch

Conversation

@wedamija
Copy link
Copy Markdown
Member

Remove the organizations:project-repository-fk-reads flag checks from all SeerProjectRepository read/write paths and related code mapping accesses in Seer code. Always use project_repository FK for queries and attribute access.

For now we'll keep organizations:project-repository-fk-reads around, since we'll have a separate pr to remove reads/writes for code mappings.

@wedamija wedamija requested a review from a team May 14, 2026 21:18
@wedamija wedamija requested review from a team as code owners May 14, 2026 21:18
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 14, 2026
Comment thread src/sentry/seer/endpoints/group_ai_autofix.py
Comment thread src/sentry/testutils/factories.py
Comment thread tests/sentry/seer/autofix/test_autofix_utils.py
Comment thread src/sentry/seer/autofix/utils.py
…itory reads

Remove the `organizations:project-repository-fk-reads` flag checks from
all SeerProjectRepository read/write paths and related code mapping
accesses in Seer code. Always use `project_repository` FK for queries
and attribute access.

The flag registration is left in place — it will be removed in a
follow-up PR that also drops the old model columns.
@wedamija wedamija force-pushed the danf/repo-remove-seer-proj-branch branch from e11636f to 1de21d9 Compare May 14, 2026 21:35
Comment thread tests/sentry/seer/autofix/test_autofix_utils.py
ordered_mappings: list[tuple[str, RepositoryProjectPathConfig]] = []
for cm in code_mappings:
repo = cm.project_repository.repository if use_project_repository_fk else cm.repository
repo = cm.project_repository.repository
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

N+1 queries from unprefetched project_repository FK access

Medium Severity

These callers now unconditionally access code_mapping.project_repository.repository, but get_sorted_code_mapping_configs still branches on the organizations:project-repository-fk-reads flag. When that flag is off, it only calls select_related("repository") — not project_repository or project_repository__repository. Each code mapping access then triggers two extra DB queries, creating an N+1 problem on the autofix hot path.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2dcb64e. Configure here.

Comment thread src/sentry/seer/autofix/utils.py
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dc296f7. Configure here.

Comment thread src/sentry/seer/autofix/utils.py
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.

1 participant