Skip to content

fix: preserve WebSocket error subscription context - #16

Merged
harley-poly merged 1 commit into
mainfrom
harley/ws-error-context
Oct 8, 2026
Merged

harley-poly merged 1 commit into
mainfrom
harley/ws-error-context

Conversation

@harley-poly

@harley-poly harley-poly commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Changes

Server error frames include subscriptionType, but the SDK drops it when constructing the callback error. Preserve it as optional WebSocketError.subscription_type on both streams and add the field to WebSocketErrorMessage. Existing error text, request IDs and dispatch behavior stay unchanged.

Document the optional context and set the patch version to 2.4.1.

Part of ISVBE-939. SDK follow-up to https://github.com/Polymarket/go-gateway-us/pull/2267; the ticket's broader marshaler work remains separate.

Testing

  • 288 tests pass on Python 3.13/websockets 17.2 and Python 3.10/websockets 13.0.
  • Local socket regressions cover both streams, known/future/unspecified types, absent context and raw messages. Removing the forwarding fails 12 cases; the four context-free cases still pass.
  • Ruff lint/format, mypy with typed consumers, and wheel/sdist build pass.

Checklist

  • Tests pass (pytest)
  • Linting passes (ruff check .)
  • Types check (mypy polymarket_us)

Note

Low Risk
Backward-compatible additive metadata on WebSocket error handling; no changes to auth, trading APIs, or connection lifecycle.

Overview
WebSocket server error frames can include subscriptionType, but the SDK previously dropped it when building WebSocketError for the error callback. This change forwards that field as an optional subscription_type attribute (alongside existing request_id) on both markets and private streams, and extends WebSocketErrorMessage typing accordingly.

Error message text, callback dispatch, and repr behavior stay the same when the server omits context. README notes the new optional fields; release is bumped to 2.4.1 with regression tests across streams and subscription-type variants.

Reviewed by Cursor Bugbot for commit 6a52685. Bugbot is set up for automated code reviews on this repo. Configure here.

@harley-poly
harley-poly merged commit 6fde8f2 into main Oct 8, 2026
11 checks passed
@harley-poly
harley-poly deleted the harley/ws-error-context branch October 9, 2026 20:55
watashi pushed a commit to watashi/polymarket-us-python that referenced this pull request Oct 12, 2026
…bution

feat(orders): builder attribution
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.

2 participants