fix: preserve structured errors in paginated methods#34
Open
aproskill81 wants to merge 2 commits intoPolymarket:mainfrom
Open
fix: preserve structured errors in paginated methods#34aproskill81 wants to merge 2 commits intoPolymarket:mainfrom
aproskill81 wants to merge 2 commits intoPolymarket:mainfrom
Conversation
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
Preserves structured API error responses in paginated client methods instead of failing with a secondary runtime error during response aggregation.
What changed
response.datawhen the response is an error objectWhy
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.dataand throwing a secondary runtime error.Adds a shared
getPaginatedResponseDataguard and updates several methods (e.g.getTrades,getOpenOrders, rewards earnings/rewards fetchers) to return... | ClobErrorResponseBodywhen pagination responses are error-shaped. ExpandsClobErrorResponseBodytyping 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.