Enabling SCIM returns a 500 for non-Okta SSO providers after a disable/re-enable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 44.8k
- Forks
- 4.9k
- Avg merge
- 21h 23m
- Merged PRs (30d)
- 607
Description
Environment
SaaS (https://sentry.io/)
Steps to Reproduce
- Set up a non-Okta SSO provider (e.g. Active Directory / SAML2) on an org.
- Settings → Auth → enable SCIM, Save.
- Disable SCIM, Save. (SCIM turns off immediately, but the underlying SCIM install is only cleaned up asynchronously.)
- Re-enable SCIM and Save before that cleanup completes.
Expected Result
Re-enabling SCIM works (or is safely handled), no server error.
Actual Result
HTTP 500. The server hits IntegrityError: duplicate key value violates unique constraint "sentry_sentryappinstalla_provider_organization_id_1bf014b7_uniq" in enable_scim (src/sentry/models/authprovider.py). The leftover-install check appears to look specifically for an okta_scim record, so for non-Okta providers it doesn't catch the org's existing _scim record and the re-create collides on the unique constraint. Okta orgs aren't affected.
Appears long-standing, not a recent regression.
See the linear case for more info.
Leaving the exact fix to the owning team.
Product Area
Settings - Auth
Link
No response
DSN
No response
Version
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/sentry/models/authprovider.py at enable_scim and trace the leftover-install check alongside the asynchronous cleanup after disabling SCIM. Verify the behavior for a non-Okta SSO provider such as Active Directory or SAML2. Done means disabling and quickly re-enabling SCIM no longer produces the duplicate-key HTTP 500.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100