Skip to content

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

Open
Sush78 wants to merge 1 commit intoPolymarket:mainfrom
Sush78:fix/balance-allowance-none-guard
Open

fix: add None guard for params in get_balance_allowance and update_balance_allowance#307
Sush78 wants to merge 1 commit intoPolymarket:mainfrom
Sush78:fix/balance-allowance-none-guard

Conversation

@Sush78
Copy link
Copy Markdown

@Sush78 Sush78 commented Mar 23, 2026

Overview

Fix AttributeError crash in get_balance_allowance and update_balance_allowance when called without 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 at the top of each method that raises a clear ValueError("params is required for ...") before accessing any attributes.

No change to method signatures or behaviour for callers who pass params correctly.

This bug was also flagged during code review of #224.

Testing instructions

Run the new test file: pytest tests/test_balance_allowance.py

Types of changes

  • Refactor/enhancement
  • Bug fix/behavior correction
  • New feature
  • Breaking change
  • Other, additional

Notes

Fixes #306

Status

  • Prefix PR title with [WIP] if necessary (changes not yet made).
  • Add tests to cover changes as needed.
  • Update documentation/changelog as needed.
  • Verify all tests run correctly in CI and pass.
  • Ready for review/merge.

Note

Low Risk
Low risk: adds early input validation and tests, without changing request construction for valid callers.

Overview
Fixes a crash in ClobClient.get_balance_allowance and ClobClient.update_balance_allowance by explicitly rejecting missing params with a clear ValueError before accessing params.signature_type.

Adds unit tests asserting both methods raise when called without parameters.

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

@Sush78 Sush78 requested a review from a team as a code owner March 23, 2026 21:49
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

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