{"record":{"id":"1d55f036eb0b7350","repo":"passbolt/passbolt_api","slug":"could-not-save-the-role-please-try-again-later","errorCode":null,"errorMessage":"Could not save the role, please try again later.","messagePattern":"Could not save the role, please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Service/Roles/RolesAddService.php","lineNumber":69,"sourceCode":"\n        $role = $rolesTable->newEntity($data, ['accessibleFields' => [\n            'name' => true,\n            'description' => true,\n            'created_by' => true,\n            'modified_by' => true,\n        ]]);\n\n        try {\n            $result = $rolesTable->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 saved.'),\n                $errors\n            );\n        } catch (Exception $e) {\n            throw new InternalErrorException(__('Could not save the role, please try again later.'), null, $e);\n        }\n\n        $this->dispatchEvent(self::AFTER_ROLE_CREATE_SUCCESS_EVENT_NAME, [\n            'uac' => $uac,\n            'role' => $result,\n        ]);\n\n        return $result;\n    }\n}\n","sourceCodeStart":51,"sourceCodeEnd":80,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Roles/RolesAddService.php#L51-L80","documentation":"RolesAddService::add wraps any non-persistence Exception from the roles save in an InternalErrorException with this message. It signals an unexpected server-side failure (DB outage, driver error) rather than a validation problem; the original exception is chained for logs.","triggerScenarios":"POST /roles when $rolesTable->saveOrFail throws a generic Exception — e.g. database connection lost, SQL error, table locked, or transaction failure during the INSERT.","commonSituations":"MySQL/MariaDB/Postgres temporarily down or restart under load, disk full on the DB server, deadlocks during bulk role creation, or network interruption between app server and database.","solutions":["Retry the request after a short delay; the message itself suggests a transient condition.","Check the application error log for the chained exception to see the root cause.","Verify database health: connectivity, disk space, and replication status.","If persistent, run `ddev refresh` (or your migrations) to confirm schema integrity for the roles table.","Contact/passbolt ops if the DB error persists — this is not fixable from the client."],"exampleFix":"// before\ncurl -X POST /roles ...  -> 500 Could not save the role (DB down)\n// after\n# restart/repair DB, then retry\ncurl -X POST /roles ...  -> 201","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await api.createRole(role);\n} catch (e) {\n  if (e.status === 500 && /could not save the role/i.test(e.message)) {\n    await delay(backoff++ * 1000); // retry transient DB failure a few times\n  } else throw e;\n}","preventionTips":["Monitor database health (connectivity, disk, replication) when role admin operations spike","Log the chained exception server-side to identify root causes quickly","Avoid bulk role creation during DB maintenance windows","Set idempotent retry with backoff on 500s"],"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"}