From 5ee8d798c4b0281a3df63ee0409b44d1c232237b Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Sat, 28 Feb 2026 10:52:52 -0600 Subject: [PATCH] store: Fix: SBA API Discord snowflake IDs returned as JSON strings not i64 --- ...e-ids-returned-as-json-strings-n-23121a.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 graph/fixes/fix-sba-api-discord-snowflake-ids-returned-as-json-strings-n-23121a.md diff --git a/graph/fixes/fix-sba-api-discord-snowflake-ids-returned-as-json-strings-n-23121a.md b/graph/fixes/fix-sba-api-discord-snowflake-ids-returned-as-json-strings-n-23121a.md new file mode 100644 index 00000000000..f0c204cefe7 --- /dev/null +++ b/graph/fixes/fix-sba-api-discord-snowflake-ids-returned-as-json-strings-n-23121a.md @@ -0,0 +1,30 @@ +--- +id: 23121a41-790a-4bf3-9a4b-39f299bc4015 +type: fix +title: "Fix: SBA API Discord snowflake IDs returned as JSON strings not i64" +tags: [sba-scout, rust, api, serde, fix, discord, json] +importance: 0.6 +confidence: 0.8 +created: "2026-02-28T16:52:52.173698+00:00" +updated: "2026-02-28T16:52:52.173698+00:00" +--- + +# Discord Snowflake IDs as JSON Strings + +**Project:** sba-scout (Rust) | **Commit:** `a18c043` + +## Problem + +The SBA league API returns Discord snowflake IDs (`gmid`, `gmid2` fields on teams) as **quoted strings** (e.g. `"258104532423147520"`) to avoid JavaScript 53-bit integer precision loss. Deserializing as `i64` fails with a type error. + +## Fix + +Changed `gm_discord_id` and `gm2_discord_id` from `Option` to `Option` in `api/types.rs` `TeamData` struct. + +## Why + +JavaScript's `Number` type can only represent integers up to 2^53 - 1 (~9 quadrillion). Discord snowflakes can exceed this, so APIs return them as strings. Rust's `i64` is fine numerically, but the JSON schema says string. + +## Pattern + +When consuming any API that originated from a JavaScript ecosystem (Discord, Twitter, etc.), treat large IDs as `String` types unless the API explicitly documents them as numbers.