Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Setting a user's external_id via the admin API returns 500 and deletes users existing external mappings if that external ID is already mapped #10846

@anoadragon453

Description

@anoadragon453

Attempting to use the create or modify user account admin api to add an external ID to a user that is already mapped to another user fails with a unique constraint db error. It should really return a HTTP 400 error instead.

In addition, any existing external IDs for the user that we were trying to modify will be erased (all entries for that user are removed from the user_external_ids table. This is due to the fact that the removal and addition of old and new IDs are separate actions:

# remove old external_ids
for auth_provider, external_id in del_external_ids:
await self.store.remove_user_external_id(
auth_provider,
external_id,
user_id,
)
# add new external_ids
for auth_provider, external_id in add_external_ids:
await self.store.record_user_external_id(
auth_provider,
external_id,
user_id,
)

They should really be bundled into a single database transaction in a new storage function so that it's not possible for the user to be left without any mappings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-MinorBlocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions