store: Fix: SBA API Discord snowflake IDs returned as JSON strings not i64
This commit is contained in:
parent
417bedac7a
commit
5ee8d798c4
@ -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<i64>` to `Option<String>` 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.
|
||||||
Loading…
Reference in New Issue
Block a user