{"record":{"id":"671baf9aab8a3e43","repo":"passbolt/passbolt_api","slug":"could-not-delete-the-role-please-try-again-later","errorCode":null,"errorMessage":"Could not delete the role, please try again later.","messagePattern":"Could not delete the role, please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Service/Roles/RolesDeleteService.php","lineNumber":105,"sourceCode":"            'deleted_by' => $uac->getId(),\n        ];\n\n        $role = $this->Roles->patchEntity($role, $data, ['accessibleFields' => [\n            'deleted' => true,\n            'deleted_by' => true,\n        ]]);\n\n        try {\n            $result = $this->Roles->saveOrFail($role);\n        } catch (PersistenceFailedException $e) { // @phpstan-ignore-line\n            $errors = $e->getEntity()->getErrors();\n\n            throw new CustomValidationException(\n                __('The role could not be deleted.'),\n                $errors\n            );\n        } catch (Exception $e) {\n            throw new InternalErrorException(__('Could not delete the role, please try again later.'), null, $e);\n        }\n\n        return $result;\n    }\n}\n","sourceCodeStart":87,"sourceCodeEnd":111,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Roles/RolesDeleteService.php#L87-L111","documentation":"RolesDeleteService::softDeleteRole wraps any generic Exception from the save (other than persistence validation) in an InternalErrorException with this message. It indicates an unexpected infrastructure-level failure while soft-deleting the role.","triggerScenarios":"DELETE /roles/{id} when $this->Roles->saveOrFail throws a generic Exception — DB connection failure, SQL error, lock timeout during the UPDATE marking deleted=true.","commonSituations":"Database outage or failover mid-request, lock contention on the roles row from concurrent admin operations, disk-full on the DB host, or driver/network errors between app and database.","solutions":["Retry after a short delay; transient DB hiccups commonly cause this.","Inspect the server error log for the chained exception (previous) to find the root cause.","Check database health: connectivity, locks, disk space.","If it happens with a specific role, verify schema integrity (run migrations) for the roles table.","Escalate to ops if persistent — not a client-fixable error."],"exampleFix":"// before\nDELETE /roles/<id>  -> 500 Could not delete the role (DB lock timeout)\n// after\n# resolve DB contention, then retry\nDELETE /roles/<id>  -> 200","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await api.deleteRole(roleId);\n} catch (e) {\n  if (e.status === 500 && /could not delete the role/i.test(e.message)) {\n    await sleep(backoffMs); // transient DB failure; retry with backoff\n  } else throw e;\n}","preventionTips":["Monitor DB health; lock contention on roles rows triggers this","Avoid concurrent admin operations on the same role","Log the chained server exception for root-cause analysis","Use bounded exponential-backoff retries on 500 responses"],"tags":["internal-error","database","roles","passbolt"],"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"}