passbolt/passbolt_api · error · InternalErrorException
Could not parse the self registration settings found in…
Error message
Could not parse the self registration settings found in database.
What it means
Thrown by SelfRegistrationGetSettingsService::getSettings when the `value` column of the self-registration settings record in the database cannot be json_decode'd (returns null). The settings payload is expected to be valid JSON, so a parse failure indicates corrupted or manually edited data. It is wrapped in an InternalErrorException (HTTP 500).
Solutions
- Inspect the self-registration settings row in the database and fix or re-serialize the `value` field as valid JSON.
- Delete the corrupted settings row so the service falls back to getDefaultSettings(), then re-save settings via the API.
- Re-run `ddev refresh` / migrations to rule out partially applied schema changes, and verify no truncation occurred.
Example fix
// before (corrupted DB row)
SELECT value FROM organization_settings WHERE property = 'self-registration';
-- value: {"providers":["email", <- truncated
// after: fix or delete the row so defaults apply
DELETE FROM organization_settings WHERE property = 'self-registration';
-- or UPDATE with valid JSON: '{"providers":["email"]}' Defensive patterns
Strategy: try-catch
Validate before calling
$value = $settings->get('value');
$decoded = json_decode($value, true);
if (!is_string($value) || json_last_error() !== JSON_ERROR_NONE) {
// repair or fall back to defaults before calling the service
} Type guard
function isValidJsonSettings(?string $raw): bool {
if ($raw === null) return false;
json_decode($raw, true);
return json_last_error() === JSON_ERROR_NONE;
} Try / catch
try {
$settings = $service->getSettings();
} catch (InternalErrorException $e) {
// fall back to defaults and log/alert about the corrupted DB row
$settings = $defaultSettingsService->getDefaultSettings();
} Prevention
- Never hand-edit organization_settings rows; always use the API.
- Use JSON columns / parameterized writes so payloads cannot be truncated.
- Add a health check that json_decode-decodes stored settings and alerts on failure.
- After DB restores or migrations, verify settings payloads parse.
When it happens
Trigger: GET /self-registration.json is called while the settings row in the `organization_settings` table contains malformed JSON in its `value` field (json_decode returns null and the value is not null itself).
Common situations: Settings were hand-edited directly in the database with invalid JSON; a migration or script truncated the JSON column; database encoding issues mangled the stored string; an old buggy writer version stored non-JSON content.
Related errors
- Could not validate the self registration settings found in…
- Could not save the action.
- Could not save the action log.
- Could not save the entity history.
- Could not save the rbacs, please try again later.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/aee2640cd5bb954e.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationGetSettingsService.php:44
* Read the self registration settings in the DB
* If not found, the default settings are returned
* A validation error is thrown if the settings in the DB are not valid
*
* @return array
* @throws \Cake\Http\Exception\InternalErrorException if the data in the DB is not valid
*/
public function getSettings(): array
{
/** @var \App\Model\Table\OrganizationSettingsTable $OrganizationSettings */
$OrganizationSettings = TableRegistry::getTableLocator()->get('OrganizationSettings');
$settings = $OrganizationSettings->getByProperty(self::USER_SELF_REGISTRATION_SETTINGS_PROPERTY_NAME);
if (is_null($settings)) {
return $this->getDefaultSettings();
}
$value = json_decode($settings->get('value'), true);
if (is_null($value)) {
throw new InternalErrorException(
__('Could not parse the self registration settings found in database.')
);
}
$form = $this->getFormFromData($value);
if (!$form->execute($value)) {
$validationException = new FormValidationException(
__('Could not validate the self registration settings found in database.'),
$form
);
throw new InternalErrorException($validationException->getMessage(), 500, $validationException);
}
return $this->getRenderedValue($settings, $form);
}
/**
* @return array<null>View on GitHub (pinned to 31c1bbc10f)