{"record":{"id":"aee2640cd5bb954e","repo":"passbolt/passbolt_api","slug":"could-not-parse-the-self-registration-settings-found-in","errorCode":null,"errorMessage":"Could not parse the self registration settings found in database.","messagePattern":"Could not parse the self registration settings found in database\\.","errorType":"exception","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationGetSettingsService.php","lineNumber":44,"sourceCode":"     * Read the self registration settings in the DB\n     * If not found, the default settings are returned\n     * A validation error is thrown if the settings in the DB are not valid\n     *\n     * @return array\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if the data in the DB is not valid\n     */\n    public function getSettings(): array\n    {\n        /** @var \\App\\Model\\Table\\OrganizationSettingsTable $OrganizationSettings */\n        $OrganizationSettings = TableRegistry::getTableLocator()->get('OrganizationSettings');\n        $settings = $OrganizationSettings->getByProperty(self::USER_SELF_REGISTRATION_SETTINGS_PROPERTY_NAME);\n        if (is_null($settings)) {\n            return $this->getDefaultSettings();\n        }\n\n        $value = json_decode($settings->get('value'), true);\n        if (is_null($value)) {\n            throw new InternalErrorException(\n                __('Could not parse the self registration settings found in database.')\n            );\n        }\n        $form = $this->getFormFromData($value);\n        if (!$form->execute($value)) {\n            $validationException = new FormValidationException(\n                __('Could not validate the self registration settings found in database.'),\n                $form\n            );\n\n            throw new InternalErrorException($validationException->getMessage(), 500, $validationException);\n        }\n\n        return $this->getRenderedValue($settings, $form);\n    }\n\n    /**\n     * @return array<null>","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/SelfRegistration/src/Service/SelfRegistrationGetSettingsService.php#L26-L62","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before (corrupted DB row)\nSELECT value FROM organization_settings WHERE property = 'self-registration';\n-- value: {\"providers\":[\"email\",  <- truncated\n\n// after: fix or delete the row so defaults apply\nDELETE FROM organization_settings WHERE property = 'self-registration';\n-- or UPDATE with valid JSON: '{\"providers\":[\"email\"]}'","handlingStrategy":"try-catch","validationCode":"$value = $settings->get('value');\n$decoded = json_decode($value, true);\nif (!is_string($value) || json_last_error() !== JSON_ERROR_NONE) {\n    // repair or fall back to defaults before calling the service\n}","typeGuard":"function isValidJsonSettings(?string $raw): bool {\n    if ($raw === null) return false;\n    json_decode($raw, true);\n    return json_last_error() === JSON_ERROR_NONE;\n}","tryCatchPattern":"try {\n    $settings = $service->getSettings();\n} catch (InternalErrorException $e) {\n    // fall back to defaults and log/alert about the corrupted DB row\n    $settings = $defaultSettingsService->getDefaultSettings();\n}","preventionTips":["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."],"tags":["database","json","configuration","cakephp"],"backgroundTag":"json-decode-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"}