Skip to content

fix(scim): create a group and its members in one transaction - #2014

Merged
snapotter-hq merged 1 commit into
snapotter-hq:mainfrom
drakeo338:claude/1763-fix
Oct 8, 2026
Merged

snapotter-hq merged 1 commit into
snapotter-hq:mainfrom
drakeo338:claude/1763-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #1763.

POST /api/v1/scim/v2/Groups inserted the team and moved each member in separate statements with no transaction. When a member write failed partway (a NUL-byte id in the test), it returned a 500 but left the team created and the first member already moved, so the IdP's retry hit a 409. The handler now creates the team and its members in one transaction, like PUT and PATCH, and the audit and warn run after commit. A rollback test sits next to the PUT one.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • New translation or i18n update
  • Documentation update
  • Test improvement
  • Refactor (no functional change)

Checklist

  • I have read CONTRIBUTING.md
  • I have signed the CLA (the bot will prompt you if not)
  • My changes follow the project's code style (Biome passes)
  • I have added or updated tests for my changes
  • All existing tests pass locally (pnpm test)
  • TypeScript compiles without errors (pnpm typecheck)
  • My PR is focused on a single concern (under 400 lines of change)
  • I have not modified CI, release, or linter configuration files

Screenshots (if applicable)

None.

Unticked boxes were not run on this commit; only scim.test.ts was run (fails before the fix, passes after).

POST /Groups inserted the team, then moved each member into it, each
straight to the database. A failure after the insert left the team and
the members already moved behind a 500, and the IdP's retry got a 409
"Group already exists".

The insert and addMembers now run in one transaction, as PUT does, and
a unique violation maps to a 409 through groupWriteConflict.

Closes snapotter-hq#1763
@snapotter-hq
snapotter-hq merged commit 8765cc3 into snapotter-hq:main Oct 8, 2026
21 checks passed
@snapotter-hq

Copy link
Copy Markdown
Owner

Thanks @drakeo338, this makes SCIM group creation all-or-nothing: a member write that fails partway no longer leaves a half-created team behind, so the IdP's retry works instead of hitting a 409. The rollback test next to the PUT one covers the failure case. It merged as submitted and will ship in the next release.

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.

SCIM POST /Groups isn't atomic: a failure after the insert leaves the team and moved members behind a 500

2 participants