{"record":{"id":"312e271d26b0295c","repo":"passbolt/passbolt_api","slug":"a-value-for-the-theme-should-be-provided","errorCode":null,"errorMessage":"A value for the theme should be provided.","messagePattern":"A value for the theme should be provided\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/AccountSettings/src/Controller/Themes/ThemesSelectController.php","lineNumber":37,"sourceCode":"use App\\Controller\\AppController;\nuse App\\Error\\Exception\\ValidationException;\nuse Cake\\Http\\Exception\\BadRequestException;\n\n/**\n * @property \\Passbolt\\AccountSettings\\Model\\Table\\AccountSettingsTable $AccountSettings\n */\nclass ThemesSelectController extends AppController\n{\n    /**\n     * Themes Select action\n     *\n     * @return void\n     */\n    public function select()\n    {\n        $theme = $this->request->getData('value');\n        if (!isset($theme) || empty($theme)) {\n            throw new BadRequestException(__('A value for the theme should be provided.'));\n        }\n\n        /** @var \\Passbolt\\AccountSettings\\Model\\Table\\AccountSettingsTable $accountSettingsTable */\n        $accountSettingsTable = $this->fetchTable('Passbolt/AccountSettings.AccountSettings');\n        try {\n            $setting = $accountSettingsTable->createOrUpdateSetting($this->User->id(), 'theme', $theme);\n        } catch (ValidationException $e) {\n            throw new BadRequestException(__('This is not a valid theme.'));\n        }\n        $this->success(__('The operation was successful.'), $setting);\n    }\n}\n","sourceCodeStart":19,"sourceCodeEnd":50,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/AccountSettings/src/Controller/Themes/ThemesSelectController.php#L19-L50","documentation":"Thrown by Gnupg::setSignKeyFromFingerprint when gnupg_addsignkey() fails for a key already present in the keyring, addressed by fingerprint. The key must exist in the keyring, hold a secret signing part, and match the supplied passphrase. The gnupg exception message is appended.","triggerScenarios":"Calling setSignKeyFromFingerprint($fingerprint, $passphrase) where the fingerprint is absent from the keyring, passphrase is wrong, or the key cannot sign (expired/revoked/no secret part).","commonSituations":"Stale fingerprint after key regeneration; keyring wiped (ephemeral CI containers); passphrase changed; fingerprint casing/whitespace mismatch.","solutions":["Confirm the fingerprint exists with `gpg --list-secret-keys --fingerprint`.","Re-import the private signing key first, then call setSignKeyFromFingerprint.","Verify the passphrase for that key.","Check key expiry/revocation status.","Ensure GNUPGHOME is correct and accessible to the PHP process."],"exampleFix":"// before\n$gpg->setSignKeyFromFingerprint($oldFingerprint, $pass); // key no longer in keyring\n// after\n$fp = $gpg->importKeyIntoKeyring($privateArmoredKey);\n$gpg->setSignKeyFromFingerprint($fp, $correctPass);","handlingStrategy":"validation","validationCode":"$out = shell_exec('GNUPGHOME=' . $home . ' gpg --list-secret-keys --with-colons ' . escapeshellarg($fingerprint));\nif ($out === null || trim($out) === '') {\n    throw new InvalidArgumentException('No secret key in keyring for ' . $fingerprint);\n}\n","typeGuard":"function isFingerprint(string $f): bool {\n    return (bool) preg_match('/^[0-9A-F]{40}$/i', str_replace(' ', '', $f));\n}\n","tryCatchPattern":"try {\n    $gpg->setSignKeyFromFingerprint($fp, $pass);\n} catch (\\Cake\\Core\\Exception\\Exception $e) {\n    $this->log('addsignkey failed for ' . $fp . ': ' . $e->getMessage());\n    throw new ServerKeyConfigurationException(previous: $e);\n}\n","preventionTips":["Check `gpg --list-secret-keys` before assuming the key is in the keyring.","Re-import the key in the same process instead of trusting persistent keyrings.","Track key rotation: update stored fingerprint and passphrase together.","Test expiry/revocation status at startup."],"tags":["openpgp","gnupg","signing","fingerprint"],"backgroundTag":"invalid-argument-value","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"}