Skip to content

[patch] Leave a bot alone when its BotNames entry is null - #67

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/66-null-bot-name
Oct 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/66-null-bot-name

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #66

What changed

BotNames.RenameFor checked whether a bot's name was already one the map gives by calling given.Trim() on every configured value. System.Text.Json reads "BotNames": { "Rock": null } without complaint, so a single null value made every call throw, for every bot. That broke RenameBot, ConnectBots and OnPlayerSpawn, so bot persona tracking never started.

The check now uses given?.Trim(). A null target means what a blank one already did: leave that bot alone. Other bots are still renamed.

Tests

  • RenameFor_ANullTarget_StillRenamesTheOtherBots: { Rock: null, Bob: "Muhlik" } renames Bob to Muhlik.
  • RenameFor_IgnoresANullTarget: the same map leaves Rock alone.
  • Both throw NullReferenceException with the fix reverted. Full suite: 741 passed, 7 skipped (unchanged), 0 failed. Release build has 0 warnings.

Generated by Claude Code

RenameFor trimmed every configured value before looking up the bot's own
key, so one "Rock": null entry threw for every bot and turned off bot
persona tracking. A null target now means the same as a blank one.

Fixes #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3f2Szc4ZLoCTbPhuX
@sonarqubecloud

Copy link
Copy Markdown

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.

One null value in the BotNames config ("Rock": null) throws NullReferenceException on every bot spawn, so no bot persona is ever tracked

2 participants