Skip to content

Treat null list-typed responses as empty (1.0.6)#20

Merged
arshka merged 1 commit into
mainfrom
fix/null-list-responses
May 2, 2026
Merged

Treat null list-typed responses as empty (1.0.6)#20
arshka merged 1 commit into
mainfrom
fix/null-list-responses

Conversation

@arshka
Copy link
Copy Markdown
Owner

@arshka arshka commented May 2, 2026

Summary

  • Kalshi's API sometimes returns {\"key\": null} for list-typed payload fields instead of {\"key\": []} or omitting the key. dict.get(key, []) only falls back to [] for missing keys — when the key is present with value null, iteration crashes with TypeError: 'NoneType' object is not iterable. This caused the integration suite's test_get_queue_positions_multiple failure on PR Fix WebSocket ts parsing for ISO 8601 timestamps (closes #18) #19's CI run.
  • Switches every list-extraction call site to dict.get(key) or [] so both null and missing are handled.
  • Covers 13 sites: paginated list helper, multi-market candlesticks, batch order place/cancel, queue positions, order groups, subaccount balances, historical candlesticks, exchange announcements, and api_keys list (sync + async pairs).
  • Also stops test_get_queue_position's cleanup from raising when the order was already filled mid-test.

Bumps version to 1.0.6.

Test plan

  • pytest tests/ (unit) — 301 passed
  • CI integration tests — should now pass since the queue_positions failure is the regression this PR fixes

🤖 Generated with Claude Code

Kalshi sometimes returns ``{"key": null}`` instead of ``{"key": []}`` or
omitting the key entirely. ``dict.get(key, default)`` only uses the
default for missing keys, so iteration over a None response crashed
with TypeError. Switch every list-extraction call site to
``dict.get(key) or []`` to handle both null and missing.

Affects: paginated list helper, multi-market candlesticks, batch order
place/cancel, queue positions, order groups, subaccount balances,
historical candlesticks, exchange announcements, and api_keys list.

Also stop the test_get_queue_position cleanup from blowing up when the
order is already gone (filled mid-test).

Bumps version to 1.0.6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arshka arshka merged commit af3ac20 into main May 2, 2026
6 checks passed
@arshka arshka deleted the fix/null-list-responses branch May 2, 2026 08:07
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.

1 participant