{"record":{"id":"67c1c5250c903629","repo":"passbolt/passbolt_api","slug":"the-s-resource-with-id-s-could-not-be-created-due-to-a","errorCode":null,"errorMessage":"The %s resource with id `%s` could not be created due to a uniqueness conflict","messagePattern":"The (.+?) resource with id `(.+?)` 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":297,"sourceCode":"        return $this;\n    }\n\n    /**\n     * Validate preconditions before attempting user creation.\n     *\n     * @throws \\Passbolt\\Scim\\Exception\\BadRequestException When \"work\" email is missing in the payload.\n     * @throws \\Passbolt\\Scim\\Exception\\ConflictException When resource id is already present.\n     */\n    private function validateCreatePreconditions(): void\n    {\n        if (!$this->email) {\n            throw new BadRequestException(\n                sprintf('No email with type \"work\" was found in the %s payload.', $this->getType()),\n                scimType: ScimException::SCIM_TYPE_INVALID_VALUE,\n            );\n        }\n        if ($this->id) {\n            throw new ConflictException(\n                sprintf(\n                    'The %s resource with id `%s` could not be created due to a uniqueness conflict',\n                    $this->getType(),\n                    $this->id\n                ),\n                scimType: ScimException::SCIM_TYPE_UNIQUENESS,\n            );\n        }\n    }\n\n    /**\n     * Find an existing user by email with a FOR UPDATE lock, loading associations.\n     *\n     * @return \\App\\Model\\Entity\\User|null\n     */\n    private function findAndLockExistingUser(): ?User\n    {\n        // Atomic locking between the uniqueness check and user insertion.","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php#L279-L315","documentation":"This ConflictException is thrown when a SCIM create (POST) payload includes an \"id\" field. SCIM ids are server-assigned, so a client supplying one during creation is treated as a uniqueness conflict in validateCreatePreconditions().","triggerScenarios":"POST /scim/v2/Users with an \"id\" property in the JSON body — typically a client replaying a resource it fetched instead of stripping the server-generated id.","commonSituations":"IdP sync loops re-POSTing existing resources, custom scripts cloning a fetched user object and POSTing it back, or switching provisioning from PATCH to full-object POST without sanitizing the payload.","solutions":["Remove the \"id\" field from the POST payload (ids are server-generated)","Use PATCH /Users/{id} or PUT instead of POST when the resource already exists","If the user exists, look it up via GET /Users?filter=userName eq ... before creating"],"exampleFix":"// before\n{\"id\":\"4c2a...\",\"userName\":\"jdoe@example.com\",\"emails\":[{\"type\":\"work\",\"value\":\"jdoe@example.com\"}]}\n// after\n{\"userName\":\"jdoe@example.com\",\"emails\":[{\"type\":\"work\",\"value\":\"jdoe@example.com\"}]}","handlingStrategy":"validation","validationCode":"if (isset($payload['id'])) {\n    unset($payload['id']); // ids are server-assigned on POST\n}\n// or bail early:\nif (!empty($payload['id'])) {\n    throw new InvalidArgumentException('Do not send \"id\" on SCIM create.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $scimUsers->create();\n} catch (\\Passbolt\\Scim\\Exception\\ConflictException $e) {\n    if ($e->getScimType() === 'uniqueness') {\n        // look up existing resource and switch to PATCH/PUT\n    }\n}","preventionTips":["Never POST objects fetched from the server; strip id, meta, and schemas before create","Use GET /Users?filter=userName eq \"...\" to detect existing resources before POST","Configure the IdP to use standard create (no id in payload) — most IdPs do this by default"],"tags":["scim","conflict","uniqueness"],"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"}