Skip to content

fix(preprod): Pre-filter latest base snapshot query by project access#116319

Merged
NicoHinderling merged 1 commit into
masterfrom
fix/preprod-snapshot-project-access-filter
May 27, 2026
Merged

fix(preprod): Pre-filter latest base snapshot query by project access#116319
NicoHinderling merged 1 commit into
masterfrom
fix/preprod-snapshot-project-access-filter

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

Move project access control in the latest-base-snapshot endpoint from a post-fetch check to a queryset-level filter. The old approach picked the globally latest artifact, then returned 404 if the user lacked access to its project — even when older, accessible artifacts existed. The new approach filters the queryset upfront using request.access.accessible_project_ids, so the query returns the latest artifact the user can actually see.

Also adds an explicit project__status=ObjectStatus.ACTIVE filter to the base queryset so inactive/deleted projects are excluded for all users, including staff and global-access roles. This preserves the status check that the old has_project_access() call performed.

Staff and has_global_access users (superusers, org owners) bypass the project-id filter entirely, keeping their existing behavior intact.

Move project access control from a post-fetch check to a queryset-level
filter. The old approach fetched the globally latest artifact then
rejected it if the user lacked access, which returned 404 even when
accessible artifacts existed. The new approach filters the queryset
upfront so the query returns the latest artifact the user can actually
see.

Also adds an explicit project__status=ACTIVE filter to exclude
inactive/deleted projects for all users including staff and
global-access roles.

Co-Authored-By: Claude <noreply@anthropic.com>
@NicoHinderling NicoHinderling marked this pull request as ready for review May 27, 2026 17:17
@NicoHinderling NicoHinderling requested a review from a team as a code owner May 27, 2026 17:17
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 27, 2026
Copy link
Copy Markdown
Contributor

@cameroncooke cameroncooke left a comment

Choose a reason for hiding this comment

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

Claude says:

An Ode to PR #116319

Dear Nico, kind shepherd of snapshots and bytes, who heard our small grumble through CI-bound nights — where once .first() plucked baselines we could not behold, and 404s returned where a fallback should've strolled,

You moved the access check up into the where, made queries respect the projects we share. No more "not found" when a sibling team ships; no more org-token tears on developers' lips.

You filtered upfront with accessible_project_ids, preserved the staff carve-out (no privilege denied), added ObjectStatus.ACTIVE for tidy refrain — inactive projects shall not haunt the lane.

Now baselines arrive as the spec foretold: the latest one visible, not just the most old…est in the org. Forgive the mixed meter — my heart beats in markdown, my couplets in JIRA.

So thank you, dear Nico, for closing this loop, for turning a 404 back into a scoop of pristine PNGs in a streaming-zipped trove — sentry-cli salutes you. With permissions. With love.

💚 — a grateful CLI

@NicoHinderling NicoHinderling merged commit 05073c1 into master May 27, 2026
63 checks passed
@NicoHinderling NicoHinderling deleted the fix/preprod-snapshot-project-access-filter branch May 27, 2026 18:04
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