Skip to content

fix: preserve structured errors in paginated methods#34

Open
aproskill81 wants to merge 2 commits intoPolymarket:mainfrom
aproskill81:fix-paginated-error-contract
Open

fix: preserve structured errors in paginated methods#34
aproskill81 wants to merge 2 commits intoPolymarket:mainfrom
aproskill81:fix-paginated-error-contract

Conversation

@aproskill81
Copy link
Copy Markdown

@aproskill81 aproskill81 commented Apr 10, 2026

Summary

Preserves structured API error responses in paginated client methods instead of failing with a secondary runtime error during response aggregation.

What changed

  • stop paginated collection methods from spreading response.data when the response is an error object
  • preserve the existing structured error contract returned by the HTTP helpers
  • align affected TypeScript return types with the actual runtime behavior
  • add coverage for paginated error handling

Why

The client already returns structured error objects from HTTP helpers. Some paginated methods were inconsistent with that pattern and could throw a secondary runtime error instead of returning the original API error.


Note

Medium Risk
Changes public return types and runtime behavior of several paginated client methods to return error objects instead of throwing during aggregation, which may require downstream callers to handle unions.

Overview
Fixes paginated collection methods to preserve structured HTTP error responses instead of attempting to spread non-array response.data and throwing a secondary runtime error.

Adds a shared getPaginatedResponseData guard and updates several methods (e.g. getTrades, getOpenOrders, rewards earnings/rewards fetchers) to return ... | ClobErrorResponseBody when pagination responses are error-shaped. Expands ClobErrorResponseBody typing and adds Vitest coverage ensuring paginated methods return { error, status } unchanged on failures.

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

@aproskill81 aproskill81 requested a review from a team as a code owner April 10, 2026 11:56
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