Skip to content

css_csp_grant/css_csp_reset bot:<name> is case-sensitive: "bot:muhlik" names a different, nonexistent persona than the connected bot "Muhlik" #68

Open

Description

@matt-edmondson

What's wrong

CorrectionTargets.Resolve (CounterStrikeProgression.Core/Admin/CorrectionTargets.cs:50-56) handles the bot: prefix by hashing whatever the admin typed:

if (text.StartsWith(BotPrefix, StringComparison.OrdinalIgnoreCase))
{
	string botName = text[BotPrefix.Length..].Trim();
	return botName.Length == 0
		? new(0, text, $"Name a bot as {BotPrefix}<name>.")
		: new(BotIds.For(botName), botName, null);
}

BotIds.For keeps case, as its docs say, so the persona id depends on the exact capitalization. Everything else an admin types for a target ignores case: exact and partial names (OrdinalIgnoreCase, lines 69-70), the prefix itself, and the BotNames config keys. Resolve also never checks the connected bots in players, so it has no chance to correct the case.

Reproduced

Scratch test against HEAD:

TargetCandidate[] players = [new(BotIds.For("Muhlik"), 3, "Muhlik")];
TargetResolution lower = CorrectionTargets.Resolve("bot:muhlik", players);
// lower.Found == true, lower.SteamId == 10000000075765951
// BotIds.For("Muhlik")               == 10000000062568863

The result counts as found and names a persona that does not exist.

Failure scenario

  1. The bot Muhlik is on the server. An admin types css_csp_reset bot:muhlik in the console.
  2. The confirmation warning names muhlik (10000000075765951). That id looks valid, so the admin confirms.
  3. SessionManager.Correct finds no session and no stored row for that id. ApplyToStoredAsync returns null, and the admin gets FailedMessage (AdminCorrection.cs:175): "they have no stored progress, or the database write failed". Nothing tells them the cause was capitalization. The real persona is untouched.

The same happens with css_csp_grant bot:muhlik -5000 when an admin is trying to remove exploited XP from a bot persona.

Why it matters

Bot names are typed by hand, often in lower case in the console. This is the documented way to correct a persona (README "Bot personas"), so a wrong-case name quietly misses its target.

Suggested fix / acceptance criteria

  • With bot:<name>, first look for a connected tracked bot whose name matches ignoring case (players already holds them), and use its id and name.
  • If no bot is connected, keep hashing the typed name. Optionally, make the error say that persona names are case-sensitive when the target has no stored progress.
  • Test: Resolve("bot:muhlik", [new(BotIds.For("Muhlik"), 3, "Muhlik")]) returns BotIds.For("Muhlik") and the name Muhlik. The existing Resolve_NamesAnOfflineBotByPrefix test still passes.

Activity

  1. matt-edmondson commented on Nov 1, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions