passbolt/passbolt_api · error · InternalErrorException

Could not save the setting, please try again later.

Error message

Could not save the setting, please try again later.

What it means

AccountSettingsTable::createOrUpdateSetting saves the account setting entity via CakePHP's save(). If save() fails without producing validation errors, the table has no more specific explanation and throws InternalErrorException with this message. It signals an unexpected persistence-layer failure rather than invalid user input.

Solutions

  1. Check database connectivity and server logs for the underlying SQL error at the time of the failure
  2. Verify the account_settings table schema matches current migrations (run pending migrations)
  3. Confirm no DB-level unique/foreign key constraint conflicts exist for the user_id/property_id pair
  4. Retry the operation once the database is healthy

Example fix

// before
$this->save($settingItem); // blindly, fails with generic 500
// after
$settingItem = $this->save($settingItem);
if (!$settingItem) {
    Log::error('Account setting save failed: ' . json_encode($this->getErrors()));
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!$this->AccountSettings->exists(['user_id' => $userId, 'property_id' => $propertyId])) {
    // ensure DB reachable: $this->AccountSettings->getConnection()->query('SELECT 1');
}

Type guard

if (!($settingItem instanceof AccountSetting) || !$settingItem->has(['user_id', 'property_id', 'value'])) { return; }

Try / catch

try {
    $table->createOrUpdateSetting($uac, $propertyId, $value);
} catch (InternalErrorException $e) {
    // log DB health details, surface 500, schedule retry
}

Prevention

When it happens

Trigger: createOrUpdateSetting() is called and $this->save($settingItem) returns false while $settingItem->getErrors() is empty — e.g. database connection failure, constraint violation not surfaced as validation error, or a DB server outage.

Common situations: Database down or misconfigured during account settings updates; disk-full MySQL/Postgres; a race or DB-level constraint (e.g. duplicate key on user_id/property_id) that bypasses application validation.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/7422a171715a872e. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltCe/AccountSettings/src/Model/Table/AccountSettingsTable.php:220

        $settingValues = ['value' => $value, 'property' => $property];
        /** @var \Passbolt\AccountSettings\Model\Entity\AccountSetting|null $settingItem */
        $settingItem = $this->find()
            ->where($settingFinder)
            ->first();

        if ($settingItem) {
            $this->patchEntity($settingItem, $settingValues);
        } else {
            $settingItem = $this->newEntity(array_merge($settingFinder, $settingValues));
        }
        if ($settingItem->getErrors()) {
            throw new ValidationException(__('This is not a valid setting.'), $settingItem, $this);
        }
        if (!$this->save($settingItem)) {
            if ($settingItem->getErrors()) {
                throw new ValidationException(__('This is not a valid setting.'), $settingItem, $this);
            }
            throw new InternalErrorException('Could not save the setting, please try again later.');
        }

        return $settingItem;
    }

    /**
     * Delete an entry for a given user and property
     *
     * @param string $userId user uuid
     * @param string $property user property
     * @return bool
     */
    public function deleteByProperty(string $userId, string $property): bool
    {
        $settingItem = $this->getByProperty($userId, $property);
        if ($settingItem !== null) {
            return $this->delete($settingItem);
        }

View on GitHub (pinned to 31c1bbc10f)