{"record":{"id":"1b1c7761d91c139f","repo":"passbolt/passbolt_api","slug":"this-is-not-a-valid-setting","errorCode":null,"errorMessage":"This is not a valid setting.","messagePattern":"This is not a valid setting\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/AccountSettings/src/Model/Table/AccountSettingsTable.php","lineNumber":214,"sourceCode":"    {\n        if (!Validation::uuid($userId)) {\n            throw new BadRequestException(__('The user identifier should be a valid UUID.'));\n        }\n\n        $settingFinder = ['user_id' => $userId, 'property_id' => $this->propertyToPropertyId($property)];\n        $settingValues = ['value' => $value, 'property' => $property];\n        /** @var \\Passbolt\\AccountSettings\\Model\\Entity\\AccountSetting|null $settingItem */\n        $settingItem = $this->find()\n            ->where($settingFinder)\n            ->first();\n\n        if ($settingItem) {\n            $this->patchEntity($settingItem, $settingValues);\n        } else {\n            $settingItem = $this->newEntity(array_merge($settingFinder, $settingValues));\n        }\n        if ($settingItem->getErrors()) {\n            throw new ValidationException(__('This is not a valid setting.'), $settingItem, $this);\n        }\n        if (!$this->save($settingItem)) {\n            if ($settingItem->getErrors()) {\n                throw new ValidationException(__('This is not a valid setting.'), $settingItem, $this);\n            }\n            throw new InternalErrorException('Could not save the setting, please try again later.');\n        }\n\n        return $settingItem;\n    }\n\n    /**\n     * Delete an entry for a given user and property\n     *\n     * @param string $userId user uuid\n     * @param string $property user property\n     * @return bool\n     */","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/AccountSettings/src/Model/Table/AccountSettingsTable.php#L196-L232","documentation":"Thrown in Gnupg::encrypt when sign-and-encrypt mode fails: either assertSignKey finds no sign key set, or gnupg_encryptsign() throws/returns false. The gnupg error text is appended in the exception case; the bare message is used when encryptsign returns false.","triggerScenarios":"Calling encryptSign/encrypt with $sign=true without having called setSignKey/setSignKeyFromFingerprint first, or with a sign key that gnupg rejects during encryptsign (passphrase, missing secret), or gnupg returning false.","commonSituations":"Forgetting key setup in a long-lived worker after clearSignKeys(); expired signing key mid-operation; encryptsign failing because the encrypt key in keyring is invalid.","solutions":["Call setSignKey (or setSignKeyFromFingerprint) with the private key before encryptSign.","Read the appended gnupg exception message for the underlying gnupg error.","Verify both the sign key and the recipient encrypt key are valid and not expired.","Check the passphrase given at setSignKey time is correct.","Retry key setup if clearSignKeys() was called earlier in the same process."],"exampleFix":"// before\n$cipher = $gpg->encryptSign($text); // no sign key set\n// after\n$gpg->setSignKey($privateKey, $passphrase);\n$gpg->setEncryptKey($recipientPublicKey);\n$cipher = $gpg->encryptSign($text);","handlingStrategy":"try-catch","validationCode":"// ensure keys are set before sign+encrypt\nif (!$gpg->isSignKeySet()) { // or track in your wrapper\n    $gpg->setSignKey($privateKey, $passphrase);\n}\n$gpg->setEncryptKey($recipientPublicKey);\n","typeGuard":"function ensureKeysReady(Gnupg $gpg): bool {\n    return $gpg->isEncryptKeySet() && $gpg->isSignKeySet();\n}\n","tryCatchPattern":"try {\n    $cipher = $gpg->encryptSign($text);\n} catch (\\Cake\\Core\\Exception\\Exception $e) {\n    $this->log('encryptsign failed: ' . $e->getMessage());\n    throw new EncryptionException(previous: $e);\n}\n","preventionTips":["Always call setSignKey before encryptSign; remember clearSignKeys() resets state.","Re-setup keys at the start of each job in long-running workers.","Check key expiry for both sign and encrypt keys.","Validate recipient public keys at registration time so encryption keys are trusted."],"tags":["openpgp","gnupg","encryption","signing"],"backgroundTag":"invalid-state-transition","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"}