fix: BuilderTradeResponse deserialization bugs (#293, #294)#297
Open
JohnGalt017 wants to merge 3 commits intoPolymarket:mainfrom
Open
fix: BuilderTradeResponse deserialization bugs (#293, #294)#297JohnGalt017 wants to merge 3 commits intoPolymarket:mainfrom
JohnGalt017 wants to merge 3 commits intoPolymarket:mainfrom
Conversation
- 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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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>, |
There was a problem hiding this comment.
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)
Collaborator
|
just have to fix the tests |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes two deserialization bugs in
BuilderTradeResponse:builderfield (Address→ApiKey): The/builder/tradesAPI returns a UUID builder key ID (e.g."019b618b-4a91-7dd9-a4c9-aadfbcbd5b95"), not an Ethereum address. Deserialization fails withinvalid string length. The TypeScript SDK correctly types this asstring. Fixes BuilderTradeResponse: builder field typed as Address but API returns UUID #294.B256fields (taker_order_hash,market,transaction_hash→Option<B256>): The API can return empty strings for pending/unfilled trades. Added#[serde(default)]+#[builder(default)]to handle gracefully. Fixes BuilderTradeResponse: B256 fields fail to deserialize when API returns empty/short strings #293.Changes
src/clob/types/response.rs:builder: Address→builder: ApiKey, threeB256fields →Option<B256>Verified
Tested against live
/builder/tradesAPI responses. Both issues confirmed reproducible with actual API JSON.Note
Medium Risk
Medium risk because it changes public response types (
builderand several hash fields) and may require downstream code updates, though the changes are narrowly scoped to deserialization behavior.Overview
Updates
BuilderTradeResponsedeserialization to match real/builder/tradesresponses. Thebuilderfield is retyped from an EthereumAddressto anApiKey(UUID), andtaker_order_hash,market, andtransaction_hashare 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.