Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#129
Open
lingster wants to merge 1 commit into
Open
Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#129lingster wants to merge 1 commit into
lingster wants to merge 1 commit into
Conversation
stake_get read `data['totalStake']` from public_user_profile, but that field was dropped from the profile query during the v2SignalsProfile/v3UserProfile refactors (commits c4451ec/6a9819f added it; later refactors removed it). `totalStake` no longer exists on the V3UserProfile type at all, so stake_get raised KeyError for every call. Query `stakeValue` (type Nmr) directly within the signals tournament and parse it to Decimal, returning None when the model has no stake. Verified against the live API: stake_get("uuazed") now returns the real stake value instead of raising. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
SignalsAPI.stake_getraisedKeyError: 'totalStake'on every call:totalStakewas once part of the profile query but was dropped when the querywas migrated to
v2SignalsProfileand thenv3UserProfile. The field nolonger exists on the
V3UserProfiletype at all, so the lookup always failed.Fix
Query the current stake field,
stakeValue(typeNmr), directly within thesignals tournament and parse it to
Decimal, returningNonefor models withno stake (instead of raising):
Testing (red/green TDD)
test_stake_get(assertsstakeValueis queried,totalStakeis not,and the request is scoped to tournament 11) and
test_stake_get_no_stake(null stake →
None). Written failing first.44 passed(live-API tests deselected);pyflakesclean.SignalsAPI().stake_get("uuazed")now returns a realDecimalinstead of raising; an unstaked model returnsNone.🤖 Generated with Claude Code