Skip to content

fix: BuilderTradeResponse deserialization bugs (#293, #294)#297

Open
JohnGalt017 wants to merge 3 commits intoPolymarket:mainfrom
JohnGalt017:fix/builder-trade-optional-b256
Open

fix: BuilderTradeResponse deserialization bugs (#293, #294)#297
JohnGalt017 wants to merge 3 commits intoPolymarket:mainfrom
JohnGalt017:fix/builder-trade-optional-b256

Conversation

@JohnGalt017
Copy link
Copy Markdown

@JohnGalt017 JohnGalt017 commented Mar 20, 2026

Summary

Fixes two deserialization bugs in BuilderTradeResponse:

Changes

  • src/clob/types/response.rs: builder: Addressbuilder: ApiKey, three B256 fields → Option<B256>

Verified

Tested against live /builder/trades API responses. Both issues confirmed reproducible with actual API JSON.


Note

Medium Risk
Medium risk because it changes public response types (builder and several hash fields) and may require downstream code updates, though the changes are narrowly scoped to deserialization behavior.

Overview
Updates BuilderTradeResponse deserialization to match real /builder/trades responses. The builder field is retyped from an Ethereum Address to an ApiKey (UUID), and taker_order_hash, market, and transaction_hash are made optional with #[serde(default)] to gracefully handle empty strings for pending/unfilled trades.

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

- builder field: Address -> ApiKey (UUID). API returns a UUID builder
  key ID, not an Ethereum address. Fixes Polymarket#294.
- B256 fields (taker_order_hash, market, transaction_hash): make
  Option<B256> with serde(default). API can return empty strings for
  pending/unfilled trades. Fixes Polymarket#293.

The TypeScript SDK (@polymarket/clob-client) correctly types builder
as string and hash fields as string. This aligns the Rust SDK.
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.

/// Hash of the taker order (optional — may be empty for pending trades).
#[serde(default)]
#[builder(default)]
pub taker_order_hash: Option<B256>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

serde(default) doesn't handle empty string B256 values

High Severity

#[serde(default)] only applies when the field is absent from the JSON — it does not handle the case where the API returns an empty string like "takerOrderHash": "". When the field is present but empty, B256 deserialization will still be attempted and fail. The same file already uses #[serde_as(as = "NoneAsEmptyString")] for identical Option<B256> patterns (e.g. condition_id, question_id) which correctly deserializes empty strings as None.

Additional Locations (2)
Fix in Cursor Fix in Web

@chaz-polymarket
Copy link
Copy Markdown
Collaborator

just have to fix the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants