-
Notifications
You must be signed in to change notification settings - Fork 732
fix: improve member identity resolve and create api #4117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,7 +102,7 @@ export async function findMemberIdentitiesByValue( | |
| ): Promise<IMemberIdentity[]> { | ||
| return qx.select( | ||
| ` | ||
| SELECT id, platform, "sourceId", type, value, verified | ||
| SELECT * | ||
|
skwowet marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Case-sensitive query misses legacy mixed-case identity rowsMedium Severity The Additional Locations (1)Reviewed by Cursor Bugbot for commit c0dfc54. Configure here.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a concern in practice — the data-sink has always written identity values as trimmed lowercase, so mixed-case rows from this API don't exist. The normalization added in this PR covers new writes going forward. |
||
| FROM "memberIdentities" | ||
| WHERE value = $(value) | ||
| AND "memberId" = $(memberId) | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing constraint handler causes 500 on concurrent requests
Medium Severity
The
throwIdentityConflictfunction only handlesuix_memberIdentities_platform_value_type_verified, but the old code also handleduix_memberIdentities_memberId_platform_value_type. The pre-check withfindMemberIdentitiesByValuedoesn't fully prevent this constraint from firing under concurrent requests — two transactions can both pass the SELECT check then race on the INSERT. When this happens, the raw DB error is re-thrown, resulting in a 500 instead of the previous clean 409 response. For an endpoint designed for idempotent retries, concurrent duplicates are a realistic scenario.Reviewed by Cursor Bugbot for commit c0dfc54. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old constraint handler for uix_memberIdentities_memberId_platform_value_type was the bug — it was throwing a 409 when the same identity already existed on the same member. The new approach is intentionally idempotent: we look up existing same-value identities first and verify them rather than throwing a conflict, per the product requirement.