{"record":{"id":"7d3250c94c08601f","repo":"passbolt/passbolt_api","slug":"the-s-resource-could-not-be-created-due-to-a-uniqueness","errorCode":null,"errorMessage":"The %s resource could not be created due to a uniqueness conflict","messagePattern":"The (.+?) resource could not be created due to a uniqueness conflict","errorType":"exception","errorClass":"Passbolt\\Scim\\Exception\\ConflictException","httpStatus":409,"severity":"error","filePath":"plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php","lineNumber":340,"sourceCode":"\n        if ($user !== null) {\n            // Load associations separately so that FOR UPDATE works with postgres/mysql both.\n            $this->Users->loadInto($user, ['Profiles', 'ScimEntries']);\n        }\n\n        return $user;\n    }\n\n    /**\n     * Throw if the existing user already has a SCIM entry.\n     *\n     * @param \\App\\Model\\Entity\\User|null $user\n     * @throws \\Passbolt\\Scim\\Exception\\ConflictException\n     */\n    private function assertNoScimEntryConflict(?User $user): void\n    {\n        if (!empty($user->scim_entry)) {\n            throw new ConflictException(\n                sprintf(\n                    'The %s resource could not be created due to a uniqueness conflict',\n                    $this->getType()\n                ),\n                scimType: ScimException::SCIM_TYPE_UNIQUENESS,\n            );\n        }\n    }\n\n    /**\n     * Register a brand-new user via the Users table.\n     *\n     * @return \\App\\Model\\Entity\\User\n     * @throws \\Passbolt\\Scim\\Exception\\ConflictException\n     */\n    private function registerNewUser(): User\n    {\n        $scimUser = $this->getScimSettingsSelectedUser();","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php#L322-L358","documentation":"This ConflictException is raised by assertNoScimEntryConflict() during create() when a non-SCIM passbolt user with the same email already exists AND that user already has a linked scim_entry row. Creating a second SCIM resource for it would break the 1:1 user↔scim_entry mapping.","triggerScenarios":"POST /scim/v2/Users with a work email matching an existing passbolt user that is already SCIM-provisioned (or a stale duplicate scim_entry row exists).","commonSituations":"IdP retrying a create after a partially failed earlier sync (user+entry created but response lost), users manually created then imported into SCIM, or leftover scim_entries from removed sync configurations.","solutions":["GET /scim/v2/Users?filter=userName eq \"...\" to check existence before POSTing; use PATCH/PUT on the existing resource","Inspect the scim_entries table for stale rows tied to the user and clean them up if the sync was re-initialized","Reconcile the IdP's externalId store with passbolt's scim_entries to restore the 1:1 mapping"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"$existing = $http->get('/scim/v2/Users?filter=userName eq \"' . urlencode($userName) . '\"');\nif (!empty(json_decode($existing->getBody(), true)['Resources'])) {\n    // resource exists: PATCH/PUT instead of POST\n}","typeGuard":null,"tryCatchPattern":"try {\n    $scimUsers->create();\n} catch (\\Passbolt\\Scim\\Exception\\ConflictException $e) {\n    if ($e->getScimType() === 'uniqueness') {\n        $user = $scimUsers->findByUserName($userName);\n        $scimUsers->patch($user['id'], $patchRequest); // adopt existing resource\n    }\n}","preventionTips":["Always filter-by-userName before create in sync logic","Reconcile scim_entries with the IdP's externalId store after restores or re-provisioning","Avoid deleting SCIM users without cleaning their linked scim_entries"],"tags":["scim","conflict","uniqueness","duplicate"],"backgroundTag":"file-already-exists","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}