Skip to content

fix: add None guard for params in get_balance_allowance and update_balance_allowance#314

Open
zyaiire wants to merge 1 commit intoPolymarket:mainfrom
zyaiire:fix/306-add-none-guard
Open

fix: add None guard for params in get_balance_allowance and update_balance_allowance#314
zyaiire wants to merge 1 commit intoPolymarket:mainfrom
zyaiire:fix/306-add-none-guard

Conversation

@zyaiire
Copy link
Copy Markdown

@zyaiire zyaiire commented Mar 28, 2026

Summary

Fixes #306

Adds a None guard to get_balance_allowance and update_balance_allowance to prevent an opaque AttributeError when called without the params argument.

Description

Both methods declare params: BalanceAllowanceParams = None as optional but immediately access params.signature_type without a None check. This causes an opaque AttributeError: '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 clear ValueError("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

  • Added None check with clear ValueError in get_balance_allowance (after auth check)
  • Added None check with clear ValueError in update_balance_allowance (after auth check)
  • Added test file tests/test_balance_allowance.py covering both cases

Testing

  • pytest tests/test_balance_allowance.py - verifies both methods raise ValueError when called without params
  • Existing test suite unchanged - no regressions for callers passing valid params

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 None guards to ClobClient.get_balance_allowance and ClobClient.update_balance_allowance, raising a clear ValueError instead of failing later with an AttributeError when called without params.

Introduces tests/test_balance_allowance.py to assert both methods require params and error deterministically.

Written by Cursor Bugbot for commit 987d557. This will update automatically on new commits. Configure here.

@zyaiire zyaiire requested a review from a team as a code owner March 28, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_balance_allowance and update_balance_allowance crash with AttributeError when params not passed

1 participant