bcgov / bcgov/SIMS

BUG: BCeID user creation can violate the username uniqueness constraint

Open
#6,573 0 comments 0 reactions 1 assignee Claimed by @uhelm View on GitHub
Bug Student
Dominant language
TypeScript
Stars
29
Forks
15
PR merge metrics
No merged PRs in 30d

Description

**Describe the Bug**

Creating a SIMS user for a BCeID identity can attempt to insert a username that already exists and violate the `users_user_name_key` unique constraint.
Consider that the issue can be from student or institution user creation.

**Expected Behaviour**

The application detects the existing user and follows the appropriate existing-user flow, or returns a handled conflict response without attempting a duplicate insert.

**Actual Behaviour**

User creation reaches PostgreSQL and fails with a unique-constraint violation.

**Steps To Reproduce**

The exact user workflow is not yet known. The failure was identified in the production PostgreSQL logs.

**Log**

```text
2026-08-31 22:04:27.486 UTC [943250] ERROR: duplicate key value violates unique constraint "users_user_name_key"
2026-08-31 22:04:27.486 UTC [943250] DETAIL: Key (user_name)=(xxxxx@bceidboth) already exists.
2026-08-31 22:04:27.486 UTC [943250] STATEMENT: INSERT INTO "sims"."users"("created_at", "updated_at", "user_name", "email", "first_name", "last_name", "is_active", "identity_provider_type", "creator", "modifier") VALUES ($1, DEFAULT, $2, $3, $4, $5, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "created_at", "updated_at", "id"
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.