Skip to content

Conversation

@heiytor
Copy link
Contributor

@heiytor heiytor commented Dec 22, 2025

When MongoDB documents with null fields are read, Go's BSON driver deserializes them as zero values (e.g., "" for strings). On update, these empty strings were written back instead of null, causing "document duplicate" errors for SAML users due to the partial unique index on username (migration 77).

This fix removes username and email from the update document when they are empty strings, preserving the original null values in the database.

When MongoDB documents with null fields are read, Go's BSON driver
deserializes them as zero values (e.g., "" for strings). On update,
these empty strings were written back instead of null, causing
"document duplicate" errors for SAML users due to the partial unique
index on username (migration 77).

This fix removes username and email from the update document when
they are empty strings, preserving the original null values in the
database.
@heiytor heiytor self-assigned this Dec 22, 2025
@heiytor heiytor requested a review from a team as a code owner December 22, 2025 14:40
@gustavosbarreto gustavosbarreto merged commit 36f651f into master Dec 27, 2025
22 of 23 checks passed
@gustavosbarreto gustavosbarreto deleted the fix/api/user-update-bson-marshall branch December 27, 2025 22:59
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.

3 participants