{"record":{"id":"2ae198a7d8790491","repo":"passbolt/passbolt_api","slug":"this-is-not-a-valid-setting-organizationsettingstable","errorCode":null,"errorMessage":"This is not a valid setting.","messagePattern":"This is not a valid setting\\.","errorType":"validation","errorClass":"App\\Error\\Exception\\CustomValidationException","httpStatus":400,"severity":"error","filePath":"src/Model/Table/OrganizationSettingsTable.php","lineNumber":187,"sourceCode":"            throw new UnauthorizedException(__('Only admin can create or update organization settings.'));\n        }\n\n        $settingId = $this->_getSettingPropertyId($property);\n        $settingFinder = ['property_id' => $settingId];\n        $settingValues = ['value' => $value, 'property' => $property];\n        $settingItem = $this->find()\n            ->where($settingFinder)\n            ->first();\n        if ($settingItem) {\n            $settingValues['modified_by'] = $control->getId();\n            /** @var \\App\\Model\\Entity\\OrganizationSetting $settingItem */\n            $settingItem = $this->patchEntity($settingItem, $settingValues);\n        } else {\n            $settingValues['created_by'] = $settingValues['modified_by'] = $control->getId();\n            $settingItem = $this->newEntity(array_merge($settingFinder, $settingValues));\n        }\n        if ($settingItem->getErrors()) {\n            throw new CustomValidationException(__('This is not a valid setting.'), $settingItem->getErrors(), $this);\n        }\n        if (!$this->save($settingItem)) {\n            throw new InternalErrorException('Could not save the setting, please try again later.');\n        }\n\n        return $settingItem;\n    }\n\n    /**\n     * Delete an organization setting\n     *\n     * @param string $property The property name\n     * @param \\App\\Utility\\UserAccessControl $control user access control object\n     * @return void\n     */\n    public function deleteSetting(string $property, UserAccessControl $control): void\n    {\n        if (!$control->isAdmin()) {","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Model/Table/OrganizationSettingsTable.php#L169-L205","documentation":"Thrown when the OrganizationSetting entity produced by patchEntity()/newEntity() fails CakePHP validation, wrapped in CustomValidationException with the entity's error list. It means the property name or value did not satisfy the table's validation rules (invalid property, wrong value format/length), not a save failure.","triggerScenarios":"Calling createOrUpdateSetting() with an unregistered property name (no matching OrganizationSetting property_id), or a value that violates validation rules (empty value, wrong type after casting, exceeding length limits) on POST/PUT /org-settings.json.","commonSituations":"Typo in the setting property name; sending a value of unexpected type (array where string expected, JSON not encoded); upgrading passbolt and sending settings whose schema/validation changed; sending blank values from a form.","solutions":["Inspect the errors array in the exception response and fix the offending field (property or value).","Use a supported setting property name as defined by OrganizationSetting::SETTINGS_PROPS / the relevant settings service.","Ensure the value matches the expected format (e.g. boolean 'true'/'false', valid JSON string, proper URL).","After an upgrade, re-check validation rules in OrganizationSettingsTable and adapt the client payload."],"exampleFix":"// before\n$this->OrganizationSettings->createOrUpdateSetting('smtpSenderEamil', 'x@y.z', $control);\n// after\n$this->OrganizationSettings->createOrUpdateSetting('smtp.senderEmail', 'x@y.z', $control);","handlingStrategy":"validation","validationCode":"if (!in_array($property, OrganizationSetting::ALLOWED_PROPERTIES, true) || trim((string)$value) === '') { throw new BadRequestException('Invalid setting.'); }","typeGuard":"function isNonEmptyString(mixed $v): bool { return is_string($v) && trim($v) !== ''; }","tryCatchPattern":"try { $setting = $this->OrganizationSettings->createOrUpdateSetting($property, $value, $control); } catch (App\\Error\\Exception\\CustomValidationException $e) { $errors = $e->getErrors(); // return 400 with $errors }","preventionTips":["Use only documented setting property names.","Validate value format (bool/JSON/URL) client-side.","Keep payloads string-typed as the API expects.","Re-check validation rules after upgrades."],"tags":["validation","organization-settings","cakephp"],"backgroundTag":"schema-validation-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"}