Skip to content

Archive SCIM users with in-use profiles instead of 500ing#1488

Merged
SachaProbo merged 1 commit into
mainfrom
SachaProbo/scim-delete-in-use-savepoint
Jul 15, 2026
Merged

Archive SCIM users with in-use profiles instead of 500ing#1488
SachaProbo merged 1 commit into
mainfrom
SachaProbo/scim-delete-in-use-savepoint

Conversation

@SachaProbo

@SachaProbo SachaProbo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

When a SCIM hard delete targets a profile that is still referenced (e.g. completed document version signatures, FK RESTRICT), profile.Delete fails with 23503 and poisons the surrounding transaction. The existing deactivate fallback then ran on the aborted transaction and failed with 25P02, surfacing to the connector as an opaque 500 and eventually disabling the bridge.

Wrap profile.Delete in a savepoint so the FK violation only rolls back the delete attempt, leaving the outer transaction healthy for the deactivate/archive fallback. Also map FK violations in Membership.Delete to ErrResourceInUse for consistency with MembershipProfile.Delete.


Summary by cubic

SCIM deletes now archive in-use profiles and return 204 instead of 500. The hard delete runs in a savepoint; on FK violations we fall back to deactivate/archive without aborting the transaction.

Tests +50 -0

  • e2e: deleting a SCIM user with a profile referenced by a completed signature returns 204 and marks the profile inactive; test client now records email/password for this flow.

Coredata +6 -0

  • Map Postgres 23503/23001 in Membership.Delete to coredata.ErrResourceInUse for consistency with MembershipProfile.Delete.

Service +13 -3

  • Wrap profile.Delete in tx.Savepoint; on coredata.ErrResourceInUse fall back to archive/deactivate and return 204.
  • Avoids transaction abort on FK RESTRICT so the fallback can proceed.

Written for commit f604c48. Summary will update on new commits.

Review in cubic

@SachaProbo SachaProbo force-pushed the SachaProbo/scim-delete-in-use-savepoint branch from 0f64140 to daf8396 Compare July 15, 2026 12:48
When a SCIM hard delete targets a profile that is still referenced
(e.g. completed document version signatures, FK RESTRICT), profile.Delete
fails with 23503 and poisons the surrounding transaction. The existing
deactivate fallback then ran on the aborted transaction and failed with
25P02, surfacing to the connector as an opaque 500 and eventually
disabling the bridge.

Wrap profile.Delete in a savepoint so the FK violation only rolls back
the delete attempt, leaving the outer transaction healthy for the
deactivate/archive fallback. Also map FK violations in Membership.Delete
to ErrResourceInUse for consistency with MembershipProfile.Delete.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
@SachaProbo SachaProbo force-pushed the SachaProbo/scim-delete-in-use-savepoint branch from daf8396 to f604c48 Compare July 15, 2026 13:44
@SachaProbo SachaProbo merged commit f604c48 into main Jul 15, 2026
19 checks passed
@SachaProbo SachaProbo deleted the SachaProbo/scim-delete-in-use-savepoint branch July 15, 2026 14:29
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.

1 participant