fix: tolerate GHIN response drift (NaN stats + Temporary status)#39
Open
doyled-it wants to merge 1 commit into
Open
fix: tolerate GHIN response drift (NaN stats + Temporary status)#39doyled-it wants to merge 1 commit into
doyled-it wants to merge 1 commit into
Conversation
GHIN's live API has diverged from the schema in two places:
1. statistics.{fairway_hits,missed_left,missed_right,missed_long,missed_short}_percent
come back as NaN (or "NaN" strings) when a round has no tracked fairway/miss
data. z.coerce.number() chokes on NaN. Added a floatSafe preprocessor that
normalizes NaN / "NaN" / empty string to null, and used it on those fields.
2. scores[*].status now includes 'Temporary' for pending scores (before the
handicap committee validates). Added 'Temporary' -> 'TEMPORARY' to the
enum and status map.
Does not touch any other behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GHIN's live API has drifted from the current schema in two places, which causes
getScoresto throw on real accounts:1. Statistics percents can be
NaN(or"NaN"strings)On rounds where the user didn't track fairway hits / miss directions, GHIN returns
NaNforfairway_hits_percent,missed_{left,right,long,short}_percent. The currentfloat(z.coerce.number()) schema rejects these.Fix: added a
floatSafepreprocessor that normalizesNaN/"NaN"/ empty string / null tonull, then validates asz.number().nullable(). Used only on the five fields that GHIN empirically sends as NaN; all other percents still use strictfloat.2.
score.statuscan be"Temporary"GHIN introduced a pending state for scores that haven't been validated by the handicap committee yet. The enum only knew
"Validated" | "UnderReview".Fix: added
"Temporary" → "TEMPORARY"to the enum and status map.Repro
Scope
Schema-only change. No behavior change for responses that already fit the old schema. No dependencies touched.