passbolt/passbolt_api · error · RuntimeException
New directory settings could not be saved.
Error message
New directory settings could not be saved.
What it means
Thrown by UpdateDirectorySettingsService::updateSettings when the CakePHP save() of the directorySync organization settings entity fails. It wraps the persistence failure (validation errors, DB write failure) into a RuntimeException so the caller knows the new LDAP/directory settings were not persisted.
Solutions
- Check the save() result's entity errors first (log $directorySyncSettings->getErrors()) to find the validation rule that failed
- Verify database connectivity and run `ddev refresh` or migrations to ensure the organization_settings table is intact
- Validate the incoming settings payload (fields like domains, usersParentGroup, customFilters) before calling save()
- Retry after clearing cache if a stale OrganizationSettings cache entry is interfering
Example fix
// before
$result = $OrganizationSettings->save($directorySyncSettings);
if (!$result) {
throw new RuntimeException(__('New directory settings could not be saved.'));
}
// after
$result = $OrganizationSettings->save($directorySyncSettings);
if (!$result) {
$errors = $directorySyncSettings->getErrors();
Log::error('Directory settings save failed: ' . json_encode($errors));
throw new RuntimeException(__('New directory settings could not be saved.') . ' ' . json_encode($errors));
} Defensive patterns
Strategy: try-catch
Validate before calling
$table = $this->fetchTable('OrganizationSettings');
$entity = $table->newEntity($data);
if ($entity->getErrors()) { /* reject before save */ } Try / catch
try {
$service->updateSettings($payload);
} catch (RuntimeException $e) {
$this->log($e->getMessage());
return $this->respondWithError('500', __('Directory settings could not be saved. Check server logs and database connectivity.'));
} Prevention
- Validate the settings payload before saving (schema/DTO validation)
- Monitor database health; the save depends on the organization_settings table
- Log entity errors on save failure for diagnosability
When it happens
Trigger: Calling updateSettings with a settings entity whose value fails entity validation, or when the underlying database write fails (connection issue, lock, constraint).
Common situations: Admin saves directory sync settings via the EE DirectorySync settings endpoint while the database is unavailable or the payload produces an invalid OrganizationSettings entity; MySQL/Postgres connection drops mid-save.
Related errors
- Could not save the action.
- Could not save the action log.
- Could not save the entity history.
- The data could not be saved. Metadata key could not be…
- Could not parse the self registration settings found in…
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/23d1db169e3882d0.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/PassboltEe/DirectorySync/src/Service/DirectorySettings/UpdateDirectorySettingsService.php:75
foreach ($value['ldap']['domains'] as $domain => $config) {
if (array_key_exists('servers', $config)) {
$value['ldap']['domains'][$domain]['hosts'] = $config['servers'];
unset($value['ldap']['domains'][$domain]['servers']);
}
}
}
// keep compatibility with old library default class value
if (empty($value['groupObjectClass'])) {
$value['groupObjectClass'] = 'groupOfNames';
}
$value['enabled'] = false;
$directorySyncSettings->set('value', json_encode($value));
$result = $OrganizationSettings
->save($directorySyncSettings);
if (!$result) {
throw new RuntimeException(__('New directory settings could not be saved.'));
}
}
}
View on GitHub (pinned to 31c1bbc10f)