{"record":{"id":"fda79973cb8e2a31","repo":"passbolt/passbolt_api","slug":"could-not-delete-the-user-0-please-try-again-later","errorCode":null,"errorMessage":"Could not delete the user {0}, please try again later.","messagePattern":"Could not delete the user (.+?), please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Model/Table/UsersTable.php","lineNumber":562,"sourceCode":"                'foreign_key' => $user->id,\n                'foreign_model' => ScimEntry::FOREIGN_MODEL_USERS,\n            ]);\n        }\n\n        // Delete all tags\n        if (Configure::read('passbolt.plugins.tags.enabled')) {\n            $ResourcesTags = TableRegistry::getTableLocator()->get('Passbolt/Tags.ResourcesTags');\n            $ResourcesTags->deleteAll(['user_id' => $user->id]);\n            /** @var \\Passbolt\\Tags\\Model\\Table\\TagsTable $Tags */\n            $Tags = TableRegistry::getTableLocator()->get('Passbolt/Tags.Tags');\n            $Tags->deleteAllUnusedTags();\n        }\n\n        // Mark user as deleted\n        $user->deleted = true;\n        if (!$this->save($user, ['checkRules' => false])) {\n            $msg = __('Could not delete the user {0}, please try again later.', $user->username);\n            throw new InternalErrorException($msg);\n        }\n\n        return $entitiesChanges;\n    }\n\n    /**\n     * Register a user\n     *\n     * @param array $data register data\n     * @param \\App\\Utility\\UserAccessControl|null $control who is requesting the registration\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if there was an issue during the save\n     * @throws \\App\\Error\\Exception\\ValidationException if the user data do not validate\n     * @return \\App\\Model\\Entity\\User entity\n     */\n    public function register(array $data, ?UserAccessControl $control = null): User\n    {\n        // if role id is empty make it a user\n        // Only admins are allowed to set the role","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Model/Table/UsersTable.php#L544-L580","documentation":"Thrown by UsersTable::softDelete() when persisting 'deleted = true' on the user entity fails via save() with checkRules disabled. The user is not removed logically, and the API returns a 500. Because validation is bypassed, the failure indicates a database or persistence-layer problem rather than bad input.","triggerScenarios":"DELETE /users/{id}.json (user deletion flow) or direct softDelete() call when the UPDATE on the users row fails — connection drop, row lock/timeout, trigger/constraint rejection, or DB read-only state.","commonSituations":"Concurrent operations locking the users row (e.g. an active session update); MySQL lock wait timeout; DB failover; disk-full; GPG/auth token side-tables with blocking triggers in customized installs.","solutions":["Retry the deletion after confirming the database is reachable and no locks exist on the users row.","Inspect error logs for the underlying SQL exception to identify the root cause.","Verify users table integrity and disk space; ensure writes are not hitting a read-only replica.","If the failure happened after partial cleanup (associated data may already be deleted), reconcile state manually or re-run the deletion flow."],"exampleFix":"// caller before\ncatch (InternalErrorException $e) { /* swallow */ }\n// after\ncatch (InternalErrorException $e) {\n    // check DB health, then retry user deletion with backoff\n}","handlingStrategy":"retry","validationCode":"if (!$this->Users->exists(['id' => $userId, 'deleted' => false])) { return; }","typeGuard":"if (!Cake\\Validation\\Validation::uuid($userId)) { throw new InvalidArgumentException('Invalid user id.'); }","tryCatchPattern":"try { $this->Users->softDelete($user); } catch (\\Cake\\Http\\Exception\\InternalErrorException $e) { // inspect DB, retry with backoff or reconcile state }","preventionTips":["Avoid concurrent edits of the same user row.","Monitor DB locks and connectivity.","Make deletion flows idempotent and retryable.","Log the underlying save() failure cause."],"tags":["database","users","delete","internal-error"],"backgroundTag":"database-write-failed","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"}