fix(shard): decode in-game serials as hex strings, not numbers #22
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/shard-serial-decode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The Guilds board (and Champs/Governors) crashed the app on open. Root cause: the public shard board DTOs typed in-game serials (and actor
webId) asLong, but the wire protocol sends them as opaque hex strings ("0x1A2B") — seedocs/link/INTEGRATION.md§1 and the C# emitters (BridgeJson.Ser/Actor). The website returns board payloads verbatim, so a guild leader / champ / governor carrying a hex serial threwJsonDecodingExceptionout of the Retrofit converter and escaped the collecting coroutine →FATAL EXCEPTION: main.Per the "API is the source of truth" rule, the DTOs are corrected to match the API.
Changes
String(data/api/dto/ShardDto.kt):ActorDto.serial&webId,ChampDto.serial,HouseDto.serial,OnlineStaffDto.serial. GuildidstaysLong— it's genuinely numeric on the wire (.Num).ChampsViewModel,HousesViewModel):champ.remove/house.decaynow readserialviastringField. PreviouslylongFieldreturnednullon a hex serial, so every board removal and live IDOC update was silently dropped — two dormant bugs the type mismatch was masking.core/result/ApiResult.kt):safeApiCallnow catchesSerializationException→HttpError(502)→ErrorKind.SERVER, so any future contract drift degrades to a retry-able error screen instead of crashing.ShardDtoTest/ApiResultTestupdated to the real hex-string wire shapes (previously encoded the wrong numeric assumption, which is why CI stayed green); addedOnlineStaffDto+ serialization-error cases.PlayerShardDto.ktthat claimed the public boards use numeric serials (the origin of the mistake).Testing
./gradlew :app:testDebugUnitTest— green.webIdactors; a livechamp.removecorrectly removes a spawn and a livehouse.decayIDOC frame adds a house — both previously dropped.AI disclosure
🤖 Generated with Claude Code
https://claude.ai/code/session_01NgyHnrNa8WwG3doxvxjuCr
The public shard board DTOs typed in-game serials (and actor webId) as Long, but the wire protocol (docs/link/INTEGRATION.md §1) sends them as opaque hex strings ("0x1A2B"). The website returns board payloads verbatim, so a guild leader / champ / governor carrying a hex serial threw JsonDecodingException out of the Retrofit converter and crashed the app on the Guilds/Champs/Governors boards. The API is the source of truth, so the DTOs are corrected to match it. - ActorDto.serial/webId, ChampDto.serial, HouseDto.serial, OnlineStaffDto.serial: Long -> String - champ.remove / house.decay live frames now read serial via stringField; longField returned null on a hex serial, silently dropping every board removal and live IDOC update - safeApiCall now catches SerializationException -> ErrorKind.SERVER, so any future contract drift degrades to a retry-able error instead of a crash (defense in depth) - DTO + result tests updated to the real hex-string wire shapes AI-assisted: authored with Claude Code (Opus 4.8). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgyHnrNa8WwG3doxvxjuCr