Skip to content

fix(objectstore): Set auth token in proxy endpoint, preprod task#112168

Draft
matt-codecov wants to merge 2 commits intomasterfrom
matth/objectstore-proxy-auth
Draft

fix(objectstore): Set auth token in proxy endpoint, preprod task#112168
matt-codecov wants to merge 2 commits intomasterfrom
matth/objectstore-proxy-auth

Conversation

@matt-codecov
Copy link
Copy Markdown
Contributor

@matt-codecov matt-codecov commented Apr 2, 2026

these appear to be the last objectstore auth integration issues to fix before we can turn on auth enforcement

proxy endpoint issue

there is a low volume of validation_failure / InvalidToken errors which only occur for requests to our batch endpoint. the only user of the batch endpoint appears to be sentry-cli, and those requests go through a Sentry proxy endpoint. the proxy endpoint forwards its request's headers mostly unmodified to Objectstore, including the Authorization header which contains a Sentry bearer token that Objectstore doesn't understand.

this PR creates a preprod objectstore session in the proxy endpoint and calls mint_token() to get a valid Objectstore token for the request

QUESTION: is it valid to assume the organization-based proxy endpoint will only deal with org-scoped resources? or do we need to make that a project-based endpoint

preprod task issue

we saw a surge in "no authorization token provided" issues coming from what i'm guessing are taskworker tasks? so i prepared the relevant task to receive a token kwarg. i assume actually setting it has to come in a separate PR, but i don't know how taskbroker tasks and whatall are deployed

Ref FS-321

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@matt-codecov matt-codecov requested a review from a team as a code owner April 2, 2026 21:01
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 2, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 2, 2026
Comment thread src/sentry/objectstore/endpoints/organization.py Outdated
Comment thread src/sentry/objectstore/endpoints/organization.py Outdated
Comment thread src/sentry/objectstore/endpoints/organization.py Outdated
Comment thread src/sentry/objectstore/endpoints/organization.py Outdated
Comment thread src/sentry/objectstore/__init__.py Outdated
@matt-codecov matt-codecov force-pushed the matth/objectstore-proxy-auth branch from 121409e to 569e889 Compare April 2, 2026 22:51
@matt-codecov matt-codecov requested a review from a team as a code owner April 2, 2026 22:51
@matt-codecov matt-codecov changed the title fix(objectstore): Replace Sentry auth header with Objectstore token in proxy endpoint fix(objectstore): Set auth token in proxy endpoint, preprod task Apr 2, 2026
Comment thread src/sentry/objectstore/__init__.py
Comment thread src/sentry/objectstore/__init__.py
Comment thread src/sentry/objectstore/__init__.py
@matt-codecov matt-codecov force-pushed the matth/objectstore-proxy-auth branch from 515c2a2 to bb78246 Compare April 2, 2026 22:59
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.

Fix All in Cursor

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

try:
session = get_preprod_session(org_id, project_id)
client_with_token = create_client(token_override=storage_token)
session = get_preprod_session(org_id, project_id, client=client_with_token)
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.

New client created per task invocation instead of singleton

Medium Severity

create_client(token_override=storage_token) is called unconditionally, creating a new Client (with its own connection pool) on every task invocation. When storage_token is None — which is always the case currently since no caller passes it — the _get_session helper already falls back to the cached singleton via default_client() when client is None. The previous code used that singleton path. Now every compare_snapshots call needlessly allocates a new client, regressing from the caching that _OBJECTSTORE_CLIENT was designed to provide. The client creation with token override only needs to happen when storage_token is not None.

Fix in Cursor Fix in Web

@matt-codecov matt-codecov marked this pull request as draft April 7, 2026 23:30
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