{"record":{"id":"3ac4be35f28ce1f5","repo":"flarum/framework","slug":"flarum-akismet-admin-akismet-settings-invalid-api-key","errorCode":null,"errorMessage":"flarum-akismet.admin.akismet_settings.invalid_api_key_message","messagePattern":"flarum-akismet\\.admin\\.akismet_settings\\.invalid_api_key_message","errorType":"validation","errorClass":"ValidationException","httpStatus":422,"severity":"error","filePath":"extensions/akismet/src/Listener/ValidateApiKey.php","lineNumber":54,"sourceCode":"        $key = Arr::get($event->settings, 'flarum-akismet.api_key');\n\n        // Not part of this save, or deliberately being cleared.\n        if ($key === null || $key === '') {\n            return;\n        }\n\n        try {\n            $valid = $this->akismet->verifyKey($key);\n        } catch (GuzzleException $e) {\n            // Can't reach Akismet right now — don't block the admin from\n            // saving; a wrong key will still surface in the log on use.\n            $this->log->warning(\"[flarum/akismet] Could not verify the API key, saving unverified: {$e->getMessage()}\");\n\n            return;\n        }\n\n        if (! $valid) {\n            throw new ValidationException([\n                'flarum-akismet.api_key' => $this->translator->trans('flarum-akismet.admin.akismet_settings.invalid_api_key_message'),\n            ]);\n        }\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":60,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/extensions/akismet/src/Listener/ValidateApiKey.php#L36-L60","documentation":"The flarum/akismet extension validates the Akismet API key when admin settings are saved by calling the Akismet service; if verification fails or returns false, it throws a ValidationException with a translated message so the settings form rejects the key. It is thrown from ValidateApiKey::handle during settings save.","triggerScenarios":"Saving the akismet admin settings (POST to the settings endpoint) while the configured flarum-akismet.api_key is empty, malformed, revoked, or the Akismet API is unreachable/returns an error so the key cannot be verified.","commonSituations":"Typing a wrong or placeholder key into the admin panel; an Akismet account whose key was deactivated; the server cannot reach rest.akismet.com (firewall, DNS, missing TLS CA certs); key from a different blog URL than the configured site URL.","solutions":["Verify the Akismet API key is valid and active for your site (check akismet.com account).","Test outbound connectivity from the server to rest.akismet.com (curl https://rest.akismet.com/1.1/verify-key).","Ensure php curl/openssl extensions and CA certificates are installed so HTTPS verification works.","If you want to save an unverified key, check the server log — verification failures are logged as a warning and the save proceeds.","Re-save with a correct key after fixing network or account issues."],"exampleFix":"// before\n'flarum-akismet.api_key' => 'YOUR_API_KEY'\n// after\n'flarum-akismet.api_key' => 'a1b2c3d4e5f6' // key verified via akismet.com/1.1/verify-key","handlingStrategy":"validation","validationCode":"$valid = (new Akismet($apiKey, $siteUrl))->verifyKey(); if (! $valid) { // block save / show error }","typeGuard":null,"tryCatchPattern":"try { $service->verifyApiKey($key); } catch (ValidationException $e) { flash($e->getErrors()['flarum-akismet.api_key'][0]); }","preventionTips":["Verify the key on akismet.com before configuring","Check server outbound HTTPS connectivity to rest.akismet.com","Keep a test command/harness to verify keys out-of-band"],"tags":["validation","api-key","third-party-api"],"backgroundTag":"missing-api-key","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}