[GameServer][Bug] Four command types were never ClientTick/Sequence-stamped on deserialization — the per-type stamp switch silently skipped them (found via SonarQube S1871) #640

Closed
opened 2026-07-17 05:38:52 +00:00 by spikerj · 1 comment
Owner

Found by taking 86 'identical branch' S1871 findings seriously instead of bulk-dismissing them (SonarQube triage loop, 2026-07-17).

MessagePackSerializer.SetClientTick/SetSequence stamped lag-compensation tick and ordering sequence via a per-concrete-type switch (44 cases each). Diffing the case list against all 48 IGameCommand implementors: DeployRoverCommand, RecallRoverCommand, SelectWeaponCommand, SetRoverHarvestTargetsCommand were missing — those commands deserialized with ClientTick=0 / Sequence=0, degrading lag compensation and ordering for exactly the rover + weapon-select paths. The failure mode was structural: adding a command type required remembering to extend two switches, with silent default-zero on a miss.

Fix (PR incoming): IGameCommand.ClientTick/Sequence gain interface setters (every implementor already had settable properties — clean compile proves it), and both switches collapse to a single interface assignment. The bug class is now impossible at compile time; the 4 missing types are fixed by construction. Also retires 86 S1871 findings.

Verified: full slnf builds clean; GameServer (913) + Common (712) + API (1296) suites pass.

**Found by taking 86 'identical branch' S1871 findings seriously instead of bulk-dismissing them (SonarQube triage loop, 2026-07-17).** `MessagePackSerializer.SetClientTick/SetSequence` stamped lag-compensation tick and ordering sequence via a per-concrete-type switch (44 cases each). Diffing the case list against all 48 `IGameCommand` implementors: **`DeployRoverCommand`, `RecallRoverCommand`, `SelectWeaponCommand`, `SetRoverHarvestTargetsCommand` were missing** — those commands deserialized with `ClientTick=0` / `Sequence=0`, degrading lag compensation and ordering for exactly the rover + weapon-select paths. The failure mode was structural: adding a command type required remembering to extend two switches, with silent default-zero on a miss. **Fix (PR incoming):** `IGameCommand.ClientTick/Sequence` gain interface setters (every implementor already had settable properties — clean compile proves it), and both switches collapse to a single interface assignment. The bug class is now impossible at compile time; the 4 missing types are fixed by construction. Also retires 86 S1871 findings. Verified: full slnf builds clean; GameServer (913) + Common (712) + API (1296) suites pass.
Author
Owner

Resolved in spikersoft-backend PR #347 (merged, 30/30 checks green). IGameCommand.ClientTick/Sequence gained interface setters and the two per-type stamp switches collapsed to single assignments — DeployRover/RecallRover/SelectWeapon/SetRoverHarvestTargets now get stamped (they deserialized with tick=0/seq=0 before), and the forgotten-case failure mode is a compile error going forward. Closing.

Resolved in spikersoft-backend PR #347 (merged, 30/30 checks green). IGameCommand.ClientTick/Sequence gained interface setters and the two per-type stamp switches collapsed to single assignments — DeployRover/RecallRover/SelectWeapon/SetRoverHarvestTargets now get stamped (they deserialized with tick=0/seq=0 before), and the forgotten-case failure mode is a compile error going forward. Closing.
Sign in to join this conversation.