passbolt/passbolt_api · error · App\Error\Exception\CustomValidationException
This is not a valid setting.
Error message
This is not a valid setting.
What it means
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.
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.
Example fix
// before
$this->OrganizationSettings->createOrUpdateSetting('smtpSenderEamil', 'x@y.z', $control);
// after
$this->OrganizationSettings->createOrUpdateSetting('smtp.senderEmail', 'x@y.z', $control); Defensive patterns
Strategy: validation
Validate before calling
if (!in_array($property, OrganizationSetting::ALLOWED_PROPERTIES, true) || trim((string)$value) === '') { throw new BadRequestException('Invalid setting.'); } Type guard
function isNonEmptyString(mixed $v): bool { return is_string($v) && trim($v) !== ''; } Try / catch
try { $setting = $this->OrganizationSettings->createOrUpdateSetting($property, $value, $control); } catch (App\Error\Exception\CustomValidationException $e) { $errors = $e->getErrors(); // return 400 with $errors } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- " " is not a valid search filter.
- " " is not a valid search filter. It is not a UTF8 string.
- " " is not a valid search filter. It should be between 1…
- " " is not a valid user filter.
- " " is not a valid value for filter .
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/2ae198a7d8790491.
Report an issue: GitHub.
Appendix: source
Thrown at src/Model/Table/OrganizationSettingsTable.php:187
throw new UnauthorizedException(__('Only admin can create or update organization settings.'));
}
$settingId = $this->_getSettingPropertyId($property);
$settingFinder = ['property_id' => $settingId];
$settingValues = ['value' => $value, 'property' => $property];
$settingItem = $this->find()
->where($settingFinder)
->first();
if ($settingItem) {
$settingValues['modified_by'] = $control->getId();
/** @var \App\Model\Entity\OrganizationSetting $settingItem */
$settingItem = $this->patchEntity($settingItem, $settingValues);
} else {
$settingValues['created_by'] = $settingValues['modified_by'] = $control->getId();
$settingItem = $this->newEntity(array_merge($settingFinder, $settingValues));
}
if ($settingItem->getErrors()) {
throw new CustomValidationException(__('This is not a valid setting.'), $settingItem->getErrors(), $this);
}
if (!$this->save($settingItem)) {
throw new InternalErrorException('Could not save the setting, please try again later.');
}
return $settingItem;
}
/**
* Delete an organization setting
*
* @param string $property The property name
* @param \App\Utility\UserAccessControl $control user access control object
* @return void
*/
public function deleteSetting(string $property, UserAccessControl $control): void
{
if (!$control->isAdmin()) {View on GitHub (pinned to 31c1bbc10f)