fix: add None guard for params in get_balance_allowance and update_balance_allowance#314
Open
zyaiire wants to merge 1 commit intoPolymarket:mainfrom
Open
fix: add None guard for params in get_balance_allowance and update_balance_allowance#314zyaiire wants to merge 1 commit intoPolymarket:mainfrom
zyaiire wants to merge 1 commit intoPolymarket:mainfrom
Conversation
…lance_allowance (fixes Polymarket#306)
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.
Summary
Fixes #306
Adds a
Noneguard toget_balance_allowanceandupdate_balance_allowanceto prevent an opaqueAttributeErrorwhen called without theparamsargument.Description
Both methods declare
params: BalanceAllowanceParams = Noneas optional but immediately accessparams.signature_typewithout a None check. This causes an opaqueAttributeError: 'NoneType' object has no attribute 'signature_type'when called without params.This adds a guard after
self.assert_level_2_auth()in each method that raises a clearValueError("params is required for ...")before accessing any attributes. The guard is placed after the auth check to maintain consistent error semantics - unauthenticated callers always get the auth error first, matching the behavior of every other method in the class.No change to method signatures or behaviour for callers who pass params correctly.
Changes
Testing
Note
This addresses the review feedback on #307 (the None guard should be placed after assert_level_2_auth() to maintain consistent error ordering).
Note
Low Risk
Low risk: adds explicit argument validation to two client methods and a small unit test, without changing request behavior for valid callers.
Overview
Adds explicit
Noneguards toClobClient.get_balance_allowanceandClobClient.update_balance_allowance, raising a clearValueErrorinstead of failing later with anAttributeErrorwhen called withoutparams.Introduces
tests/test_balance_allowance.pyto assert both methods requireparamsand error deterministically.Written by Cursor Bugbot for commit 987d557. This will update automatically on new commits. Configure here.