Repository navigation
fix(data-export): Refuse exports from callers with no user - #129637
Merged
Merged
Conversation
This was referenced Nov 3, 2026
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 04:03
250b3ae to
3bfabab
Compare
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 04:41
3bfabab to
8dccd62
Compare
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 19:53
8dccd62 to
2ef4b60
Compare
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 20:02
2ef4b60 to
315e058
Compare
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 20:09
315e058 to
c5e54ea
Compare
azulus
approved these changes
Nov 3, 2026
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 3, 2026 20:51
c5e54ea to
045cf03
Compare
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
fix/data-export-requires-user
branch
3 times, most recently
from
November 4, 2026 00:44
89d8511 to
af9ae26
Compare
An export is emailed to and downloaded by its user. For an API key or org token, the endpoint created the export and scheduled its task, then returned 500 because the response serializer looks the user up. Each attempt left an export nobody could fetch, and the get_or_create on user_id=None matched other no-user callers' unfinished exports. require_user() refuses these callers up front (401; 403 for a service account), and data_export.py leaves the request.user allowlist.
gricha
force-pushed
the
fix/data-export-requires-user
branch
from
November 4, 2026 01:15
af9ae26 to
b8a07c8
Compare
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
…129629) Two personal-state checks go through `sentry.auth.principal`, which drops them from the `request.user` allowlist (12 → 10). - **Prompt dismissal** (`PUT prompts-activity`) is a personal write, so it calls `require_user()`. A legacy API key got 201 while nothing was saved (the insert with no user failed and the error was swallowed); it now gets 401. Production had no PUT without a user in the last 30 days (0 of 3,456 sampled). A service account still gets 403 `user-required`. - **Dashboard edit permission** reads the caller through `acting_user_id()`, the same value for users and token callers. A service account on a restricted dashboard still gets 403, now the generic permission error instead of `user-required`. Data export stays on the allowlist here: callers with no user created exports nobody could get, which #129637 fixes on its own. `test_api_key_cannot_dismiss` fails without this change: ``` E assert 201 == 401 FAILED tests/sentry/api/endpoints/test_prompts_activity.py::PutPromptsActivityTest::test_api_key_cannot_dismiss ``` With it, the prompts and dashboards suites pass.
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
… and client config (#129630) Four one-off `request.user` reads, which drops their files from the allowlist (10 → 6). What's left is member management (#129638), data export (#129637) and `group_integration_details.py` (#129639); #129640 then deletes the allowlist. - **Agent tokens:** `resolve_minting_principal()` rejects any caller with no user (`has_user`), not just `AnonymousUser`. A service account used to resolve to a *user* principal carrying its `ServiceAccountId` and fail later; it now gets the same "Minting requires a user principal" 403 as an anonymous caller. The new assertion fails without this change: ``` E AssertionError: assert AgentPrincipal(type=<AgentPrincipalType.USER: 'user'>, id=ServiceAccountId(service_account_id=1)) is <MintingPrincipalRejection.UNSUPPORTED: 'unsupported'> ``` - **Release serialization** takes a `RequestPrincipal`. It only forwards the caller to `serialize()` and `serialize_generic_user()`, which already take one, so this is type-only. - **Notebooks** read the caller through `acting_user_id()`; same value for users and token callers. - **Client config** is built only from Django views, so its request is typed as `HttpRequest`. Type-only.
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.
Data export POSTs from a caller with no user (a legacy API key or an org auth token) created an export nobody could get, then returned 500.
An export is emailed to and downloaded by its user. For a caller with no user the endpoint still ran
get_or_create(user_id=None, ...), scheduled the export task, and then crashed serializing the response, because the serializer looks the user up. Each attempt left an export that no one could download (the details endpoint needs a user since #129442). Theuser_id=Nonelookup also matched other no-user callers' unfinished exports with the same query.require_user()now refuses these callers before anything is created: 401 for API keys, 403user-requiredfor a service account. (Org auth tokens only carryorg:ci, so the permission check already returned 403.) Users are unaffected. Production had no export POST without a user in the last 30 days (0 of 3,968 sampled transactions), so no working integration relies on this.test_api_key_cannot_exportfails without the fix:With it,
test_data_export.pypasses:49 passed. Also dropsdata_export.pyfrom therequest.userallowlist (6 → 5).