{"record":{"id":"5f10862f05e00dc4","repo":"passbolt/passbolt_api","slug":"mfa-setting-yubikey-id-is-not-set","errorCode":null,"errorMessage":"MFA setting Yubikey Id is not set.","messagePattern":"MFA setting Yubikey Id is not set\\.","errorType":"exception","errorClass":"RecordNotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltCe/MultiFactorAuthentication/src/Utility/MfaAccountSettingsYubikeyTrait.php","lineNumber":32,"sourceCode":" * @link          https://www.passbolt.com Passbolt(tm)\n * @since         2.5.0\n */\nnamespace Passbolt\\MultiFactorAuthentication\\Utility;\n\nuse Cake\\Datasource\\Exception\\RecordNotFoundException;\n\ntrait MfaAccountSettingsYubikeyTrait\n{\n    /**\n     * Return the yubikey id\n     *\n     * @throws \\Cake\\Datasource\\Exception\\RecordNotFoundException if URI is not set\n     * @return mixed\n     */\n    public function getYubikeyId(): mixed\n    {\n        if (!isset($this->settings[MfaSettings::PROVIDER_YUBIKEY][self::YUBIKEY_ID])) {\n            throw new RecordNotFoundException(__('MFA setting Yubikey Id is not set.'));\n        }\n\n        return $this->settings[MfaSettings::PROVIDER_YUBIKEY][self::YUBIKEY_ID];\n    }\n\n    /**\n     * Check if YubikeyUserId is set\n     *\n     * @return bool\n     */\n    public function isYubikeyUserIdSet(): bool\n    {\n        try {\n            $this->getYubikeyId();\n        } catch (RecordNotFoundException $exception) {\n            return false;\n        }\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/MultiFactorAuthentication/src/Utility/MfaAccountSettingsYubikeyTrait.php#L14-L50","documentation":"getYubikeyId() (MfaAccountSettingsYubikeyTrait) returns the Yubikey ID stored for the account. It throws RecordNotFoundException when settings['yubikey']['id'] is missing, meaning the Yubikey provider was never configured for this user. isYubikeyUserIdSet() relies on it.","triggerScenarios":"Calling getYubikeyId() or isYubikeyUserIdSet() when the yubikey settings entry has no 'id' key — user never enrolled a Yubikey, or settings saved without the id field.","commonSituations":"Login-time Yubikey checks for users who enrolled a different provider; account settings payload missing the yubikey.id field after import/migration; tests with incomplete fixture settings; reading settings before the yubikey setup form was submitted.","solutions":["Confirm the user actually enabled the yubikey provider before probing for its id (check enabled providers first).","Wrap in try/catch on RecordNotFoundException and treat the Yubikey id as unset.","Complete the Yubikey enrollment flow so settings[yubikey][id] gets persisted.","Verify the stored account settings JSON contains the 'yubikey' => ['id' => ...] structure."],"exampleFix":"// before\n$yubikeyId = $mfaAccountSettings->getYubikeyId();\n// after\ntry {\n    $yubikeyId = $mfaAccountSettings->getYubikeyId();\n} catch (\\Cake\\Datasource\\Exception\\RecordNotFoundException $e) {\n    $yubikeyId = null; // no yubikey configured\n}","handlingStrategy":"try-catch","validationCode":"$yubikeyId = null;\ntry { $yubikeyId = $s->getYubikeyId(); } catch (RecordNotFoundException $e) {}","typeGuard":null,"tryCatchPattern":"try { $id = $s->getYubikeyId(); } catch (\\Cake\\Datasource\\Exception\\RecordNotFoundException $e) { $id = null; }","preventionTips":["Check enabled providers before accessing provider-specific settings","Complete Yubikey enrollment so settings[yubikey][id] is persisted","Use isYubikeyUserIdSet-style wrappers with catch semantics instead of direct access"],"tags":["mfa","yubikey","record-not-found"],"backgroundTag":"record-not-found","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"}