{"record":{"id":"0c105862e04aa0f8","repo":"passbolt/passbolt_api","slug":"errormessage","errorCode":null,"errorMessage":"$errorMessage","messagePattern":"\\$errorMessage","errorType":"exception","errorClass":"RecordNotFoundException","httpStatus":404,"severity":"error","filePath":"plugins/PassboltCe/MultiFactorAuthentication/src/Service/MfaOrgSettings/MfaOrgSettingsDuoService.php","lineNumber":156,"sourceCode":"\n        if (count($errors) !== 0) {\n            $msg = __('Could not validate Duo configuration');\n            throw new CustomValidationException($msg, $errors);\n        }\n    }\n\n    /**\n     * Get Duo provider setting.\n     *\n     * @param string $settingKey organization settings key\n     * @param string $errorMessage error message if organization settings key is not found\n     * @return string\n     * @throws \\Cake\\Datasource\\Exception\\RecordNotFoundException if setting is missing\n     */\n    private function getSetting(string $settingKey, string $errorMessage): string\n    {\n        if (!isset($this->settings[MfaSettings::PROVIDER_DUO][$settingKey])) {\n            throw new RecordNotFoundException($errorMessage);\n        }\n\n        return $this->settings[MfaSettings::PROVIDER_DUO][$settingKey];\n    }\n}\n","sourceCodeStart":138,"sourceCodeEnd":162,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/MultiFactorAuthentication/src/Service/MfaOrgSettings/MfaOrgSettingsDuoService.php#L138-L162","documentation":"Generic accessor getSetting() throws RecordNotFoundException when a requested Duo setting key is absent from the loaded organization settings array. Messages are supplied by getDuoClientId/getDuoClientSecret/getDuoApiHostname.","triggerScenarios":"Calling getDuoClientId(), getDuoClientSecret(), or getDuoApiHostname() on a MfaOrgSettingsDuoService built from settings that do not contain the duo provider entry or the specific key.","commonSituations":"Duo provider never configured; settings JSON saved under a different provider key; accessing Duo accessors when org settings only contain totp; partially written settings after a failed save.","solutions":["Check provider is enabled/configured (MfaOrgSettings::get()->isProviderEnabled(PROVIDER_DUO)) before reading Duo accessors.","Re-save complete Duo settings via POST /mfa/policies/duo.json.","Inspect the mfa org settings record in the database for the duo key.","Ensure the service is constructed with MfaOrgSettings::get()->getSettings() for the correct organization."],"exampleFix":"// before\n$hostname = $duoService->getDuoApiHostname();\n// after\nif (!MfaOrgSettings::get()->isProviderEnabled(MfaSettings::PROVIDER_DUO)) {\n    throw new BadRequestException('Duo provider is not configured.');\n}\n$hostname = $duoService->getDuoApiHostname();","handlingStrategy":"try-catch","validationCode":"if (!MfaOrgSettings::get()->isProviderEnabled(MfaSettings::PROVIDER_DUO)) {\n    throw new BadRequestException('Duo provider not configured.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $clientId = $duoService->getDuoClientId();\n} catch (RecordNotFoundException $e) {\n    // treat as provider-not-configured\n    return null;\n}","preventionTips":["Gate Duo accessors behind a provider-enabled check.","Persist complete Duo settings atomically to avoid partial saves.","Backfill defaults or fail explicitly when the provider is disabled."],"tags":["mfa","duo","configuration","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"}