{"record":{"id":"347bbcec08a4d7fc","repo":"passbolt/passbolt_api","slug":"unexpected-error-when-trying-to-delete-the-user","errorCode":null,"errorMessage":"Unexpected error when trying to delete the user.","messagePattern":"Unexpected error when trying to delete the user\\.","errorType":"http","errorClass":"ConflictException","httpStatus":409,"severity":"error","filePath":"plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php","lineNumber":966,"sourceCode":"\n        try {\n            $result = $this->Users->softDelete($this->userEntity);\n            $errors = $this->userEntity->getErrors();\n            if (!$result || $errors !== []) {\n                if (isset($errors['id']['soleOwnerOfSharedContent'])) {\n                    // @todo: send email\n                    throw new ConflictException(\n                        'The user cannot be deleted because its the sole owner of shared content'\n                    );\n                }\n                throw new ConflictException('The User resource could not be deleted due to validation failure');\n            }\n        } catch (Exception $e) {\n            ScimLog::error(sprintf('Unable to delete the user with id `%s`', $this->userEntity->id));\n            ScimLog::error($e->getMessage());\n            ScimLog::error($e->getTraceAsString());\n\n            throw new ConflictException('Unexpected error when trying to delete the user.');\n        }\n\n        return $this;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function toSCIM(): array\n    {\n        if (!$this->id) {\n            throw new ScimException(\n                sprintf(\n                    'The values of the %s resource has not been set for the `toSCIM` operation',\n                    $this->getType()\n                )\n            );\n        }","sourceCodeStart":948,"sourceCodeEnd":984,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Resource/UserScimResource.php#L948-L984","documentation":"Catch-all in UserScimResource::delete(): any unexpected Exception thrown during the delete flow (outside the ConflictExceptions) is logged and rethrown as a generic ConflictException 'Unexpected error when trying to delete the user.' (HTTP 409). The original exception message is only available in ScimLog, making this error opaque to the SCIM client.","triggerScenarios":"DELETE /scim/v2.0/Users/{id} when softDelete() throws rather than returning false: database connection failure, lock timeout, exception raised inside a model event listener, etc.","commonSituations":"Database outage or migration pending during IdP bulk deprovisioning; a plugin hook throwing during beforeDelete; infrastructure issues (deadlock, read-only replica) during delete.","solutions":["Read ScimLog entries for 'Unable to delete the user with id `...`' — the original exception message and trace are logged there.","Verify database health (connectivity, migrations up to date, no read-only mode) with `ddev refresh` or equivalent, then retry the DELETE.","Retry the request after transient failures; if it persists, report with the logged stack trace.","Exclude the user from the SCIM sync scope until the underlying issue is fixed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $client->delete(\"/scim/v2.0/Users/{$id}\");\n} catch (ServerException | ConnectException $e) {\n    sleep($backoff); // transient db/infra failure: retry with backoff\n    retryDelete($id);\n}","preventionTips":["Ensure database connectivity and completed migrations before bulk SCIM syncs.","Add bounded retry with backoff for DELETE calls (transient failures surface as this generic 409).","Monitor server health and ScimLog during IdP-driven deprovisioning waves.","Avoid running bulk deletes during maintenance windows or migrations."],"tags":["scim","user-deletion","unexpected-error","database"],"backgroundTag":"api-error-response","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"}