Skip to content

fix: treat 403 from self-client as operational error#11805

Open
stilla[bot] wants to merge 1 commit into
mainfrom
stilla/fix-403-self-client-operational-error
Open

fix: treat 403 from self-client as operational error#11805
stilla[bot] wants to merge 1 commit into
mainfrom
stilla/fix-403-self-client-operational-error

Conversation

@stilla

@stilla stilla Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Problem

A 403 response from the Polar self-client (e.g., polar.portal.list_payment_methods) was raising PolarSelfClientError — a non-retryable client error — causing Sentry alerts as unexpected failures.

Fix

Add 403 to the PolarSelfClientOperationalError condition in _raise_error. A 403 can occur transiently (e.g., during customer session setup race conditions) and should be treated as an operational error, not a programming/client error.

# Before
if error.status_code == 429 or error.status_code >= 500:
    raise PolarSelfClientOperationalError(message) from error

# After
if error.status_code in (403, 429) or error.status_code >= 500:
    raise PolarSelfClientOperationalError(message) from error

Fixes Sentry issue: SERVER-4M0

Sent by @Yopi from Operational error fix.

Co-Authored-By: Stilla <stilla@stilla.ai>
@stilla stilla Bot requested review from a team and frankie567 as code owners May 21, 2026 07:37
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polar Ready Ready Preview, Comment May 21, 2026 7:40am
polar-sandbox Ready Ready Preview, Comment May 21, 2026 7:40am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

OpenAPI Changes

No changes detected in the OpenAPI schema.

@Yopi Yopi left a comment

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.

Since we know the token is valid, the 403s comes from the user not having access

@frankie567

frankie567 commented May 21, 2026

Copy link
Copy Markdown
Member

Don't you fear this will hide real error/mistakes in the future? For example, if we miss a team owner change, we might try to do stuff on behalf of the wrong member?

@github-actions

Copy link
Copy Markdown
Contributor

Preview Environment
URL: https://polar-preview-vm.taildbff7b.ts.net/pr-11805
API: https://polar-preview-vm.taildbff7b.ts.net/pr-11805/v1/
Logs: backend
SHA: 9f49dc05db1ed176bf7ab96bfd9a2aa8e7ababbd

@Yopi

Yopi commented May 21, 2026

Copy link
Copy Markdown
Contributor

Don't you fear this will hide real error/mistakes in the future? For example, if we miss a team owner change, we might try to do stuff on behalf of the wrong member?

Hmm. That's a good point. I was thinking that it would only be when someone tries to access something they don't have access to legitimately. I'd like to get rid of false positives in alerts somehow though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants