Skip to content

Stop the bot crashing when hosted verification is unavailable - #38

Merged
valzargaming merged 1 commit into
mainfrom
claude/verifier-unavailable-no-crash
Oct 29, 2026
Merged

valzargaming merged 1 commit into
mainfrom
claude/verifier-unavailable-no-crash

Conversation

@valzargaming

@valzargaming valzargaming commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Moderator::scrutinizeCkey() runs from GameServer's 180-second serverinfo timer for every connected player. While hosted verification is unavailable, Verifier::get() throws VerifierException('Hosted verification unavailable'). Nothing caught it, so the bot died with:

PHP Fatal error:  Uncaught Civ13\Exceptions\VerifierException: Hosted verification unavailable in src/Civ13/Verifier.php:1187
#0 src/Civ13/Moderator.php(172): Civ13\Verifier->get('ss13', 'valzargaming')
#1 src/Civ13/GameServer.php(510): Civ13\Moderator->scrutinizeCkey('valzargaming')

This took the portable VZGCivilizationbot (Persistence/Gaia server) offline on 2026-10-28 10:32 and again on 2026-10-29 12:20, and control.php start does not relaunch after a crash exit.

Changes, in Moderator only:

  • scrutinizeCkey(): if verification status is unknown, skip the new-account checks and log a warning. An unknown status is never treated as unverified, so verified players are not banned during an outage.
  • Chat moderation: if the admin lookup throws, skip the ban for that message and log a warning, instead of crashing or risking a ban on staff.

Testing

  • php -l src/Civ13/Moderator.php: no syntax errors.
  • Not covered by an automated test; Moderator needs a full Civ13 instance. The live check is the portable bot staying up with a player connected while verification is unavailable.

Not in this PR

  • control.php start does not restart the bot after an abnormal exit (only after a reload request).
  • Repeated Unhandled promise rejection ... VerifierException and Could not create a MessageBuilder for test1714 (GameServer.php:579) in stderr; they are logged but not fatal.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved moderation reliability when account verification is unavailable. New-account checks and chat enforcement are skipped rather than proceeding with incomplete verification, and a warning is logged.

Moderator::scrutinizeCkey runs from GameServer's serverinfo timer for every
connected player. Verifier::get throws VerifierException while hosted
verification is unavailable, and the uncaught throw was a PHP fatal that took
VZGCivilizationbot offline on 2026-10-28 and again on 2026-10-29.

When verification status is unknown, skip the new-account checks (never treat
the player as unverified) and skip the chat-moderation ban (admin status is
unknown), logging a warning instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

Moderator verification lookups now catch and log VerifierException. Account scrutiny returns without running new-account checks when lookup fails. Chat moderation returns false before the admin check and warning or ban flow when lookup fails.

Changes: Moderator Verifier Error Handling

Layer / File(s) Summary
Handle verifier lookup failures
src/Civ13/Moderator.php
scrutinizeCkey logs verifier exceptions and skips subsequent new-account checks. __relayViolation logs verifier exceptions and returns false before the admin check and warning or ban flow.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: High · up to bb95e

The PR's goal is to keep the bot online during verification outages, but the periodic player check can still crash it. That happens when a newly seen player with existing log history is scrutinized, because the verification lookup inside ckeyinfo runs before the new guard. Chat relaying also still fails during an outage. That failure makes logins return an error and skip the new-account and panic checks. Both gaps should be fixed before merging.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@valzargaming
valzargaming merged commit 5c6e2b8 into main Oct 29, 2026
26 of 27 checks passed
valzargaming added a commit that referenced this pull request Oct 29, 2026
…unavailable (#39)

#38 caught VerifierException in Moderator's own verifier lookups, but
scrutinizeCkey reaches Verifier::get through Civ13::ckeyinfo() too, and the
plain loop timer turned that throw into a PHP fatal again (2026-10-29 13:19).
Catch any throwable per ckey in the serverinfo timer and log it. The round
embed's verified-player list also threw from the same lookup, so the embed
was never built; omit that list while verification is unavailable.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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