Skip to content

Say why Akismet turned a comment away - #181

Merged
ssavutu merged 1 commit into
mainfrom
fix/akismet-error-diagnostics
Aug 5, 2026
Merged

Say why Akismet turned a comment away#181
ssavutu merged 1 commit into
mainfrom
fix/akismet-error-diagnostics

Conversation

@ssavutu

@ssavutu ssavutu commented Aug 5, 2026

Copy link
Copy Markdown
Member

A spam comment sat in Pending after Akismet was switched on. Akismet was working as designed — it was rejecting our key, and the client had no way to say so.

Akismet answers every comment check with HTTP 200 and explains itself in the x-akismet-debug-help header, never in the body. All the log had was:

WARN akismet comment check failed; comment requires moderation
     error=akismet returned unexpected response "invalid"

The actual reason (Empty "api_key" value) only came out of a manual curl against the API from Delta. Meanwhile every comment, spam included, was falling back to pending — safe, but silently unfiltered.

Changes

  • Read x-akismet-debug-help and carry it into the error text, on both the HTTP-status and unreadable-body paths.
  • Map body invalid to a new akismet.ConfigError (with IsConfigError), separating "the key or blog URL is wrong" from a timeout.
  • The comment handler logs a config rejection at ERROR — nothing is being filtered until an operator acts — and keeps WARN for transient failures. Both still fall back to pending.
  • Log x-akismet-alert-code / -msg. These accompany a successful verdict to flag account problems, notably a plan that does not cover a commercial site. The verdict is returned unchanged.

Testing

Four new tests cover the config-error mapping, debug help on both error paths, and a verdict surviving an account alert. go vet ./... and go test ./... pass.

The production key has since been replaced; a guaranteed-spam probe against the current key returns true with no alert header.

Note: /etc/triangle-cms/cms.env is read at container create time, so key changes need a recreate, not a restart.

🤖 Generated with Claude Code

Akismet answers every comment check with HTTP 200 and puts the reason in
the x-akismet-debug-help header, so a rejected key looked like nothing
worse than "unexpected response \"invalid\"" in the logs while every
comment, spam included, quietly fell back to pending.

Read that header and carry it into the error. Body "invalid" now maps to
a ConfigError, which the comment handler logs at ERROR because nothing is
being filtered until an operator fixes the key or the blog URL; transient
failures keep their warning. Account alerts, which ride along with a good
verdict to flag a plan that does not cover this site, are logged without
disturbing the verdict.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ssavutu
ssavutu merged commit 4e02453 into main Aug 5, 2026
6 checks passed
@ssavutu
ssavutu deleted the fix/akismet-error-diagnostics branch August 5, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant