-
Notifications
You must be signed in to change notification settings - Fork 15
feat(data): align combo fields and history ceilings #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kartojal
wants to merge
4
commits into
main
Choose a base branch
from
feature/dev-436-track-data-api-contract-changes-from-docs-pr-263-in
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3fd9876
feat(data): align combo fields and history ceilings
kartojal bf9451f
fix(data): align history coverage with repository rules
kartojal fab9753
fix(data): address history pagination review
kartojal a438dbf
fix(data): address brunson follow-up
kartojal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@polymarket/bindings": patch | ||
| "@polymarket/client": patch | ||
| --- | ||
|
|
||
| Preserve exact combo entry-basis fields and reject Data history pagination past documented offset ceilings. |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { UserInputError } from './errors'; | ||
| import { | ||
| decodeOffsetCursor, | ||
| encodeOffsetCursor, | ||
| offsetContinuation, | ||
| paginate, | ||
| } from './pagination'; | ||
|
|
||
| describe('capped offset pagination', () => { | ||
| it('allows the last documented offset', () => { | ||
| const cursor = encodeOffsetCursor({ offset: 10_000, pageSize: 500 }); | ||
|
|
||
| expect(decodeOffsetCursor(cursor, 1, 10_000)).toEqual({ | ||
| offset: 10_000, | ||
| pageSize: 500, | ||
| }); | ||
| }); | ||
|
|
||
| it('rejects a supplied cursor above the ceiling', () => { | ||
| const cursor = encodeOffsetCursor({ offset: 10_001, pageSize: 20 }); | ||
|
|
||
| expect(() => decodeOffsetCursor(cursor, 20, 10_000)).toThrow( | ||
| UserInputError, | ||
| ); | ||
| }); | ||
|
|
||
| it('signals truncation by rejecting the continuation after the ceiling', () => { | ||
| const continuation = offsetContinuation( | ||
| { offset: 10_000, pageSize: 500 }, | ||
| true, | ||
| ); | ||
|
|
||
| expect(continuation.hasMore).toBe(true); | ||
| expect(() => | ||
| decodeOffsetCursor(continuation.nextCursor, 500, 10_000), | ||
| ).toThrow(UserInputError); | ||
| }); | ||
|
|
||
| it('rejects synchronous page setup failures through the promise contract', async () => { | ||
| const failure = new UserInputError('Invalid page'); | ||
| const paginator = paginate(() => { | ||
| throw failure; | ||
| }); | ||
|
|
||
| await expect(paginator.firstPage()).rejects.toBe(failure); | ||
| }); | ||
| }); |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ClickHouse fallback serializes these unavailable decimal fields as
"". We already haveOptionalDecimalStringSchemaspecifically for this wire behavior, normalizing""tonullwhile preserving populated decimal strings. Can we use it forgross_entry_cost_usdcandentry_fees_usdcinstead ofDecimalStringSchema.nullish(), and cover the empty fallback shape? Otherwise""is branded as a validDecimalString.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed —
[bug]. Verified at the source inPolymarket/data-api:packages/api/pkg/repository/clickhouse/v1_combos.go:122buildsCombinatorialPositionPayloadwithoutGrossEntryCostUsdc/EntryFeesUsdc— the CH arm never scans them. Onlypg_repository.gopopulates them.packages/api/pkg/payload/combos_payloads.go:16-17declares both as plainstringwith noomitempty, so a CH-served page emits"gross_entry_cost_usdc": ""— present, non-null, empty.Two consequences beyond what you flagged:
.nullish()is dead code on this endpoint. Because those struct fields are non-pointer and lackomitempty,null/absent is unreachable;""is the only missing encoding.DecimalStringSchemaisz.string().transform(toDecimalString)with no non-empty check, so""is brandedDecimalStringand flows straight intogrossEntryCostUsdc − entryFeesUsdc.packages/client/tests/integration/portfolio.test.ts:110-111assertsexpect.any(String), which passes on"". Even a live CH-served page wouldn't fail the suite — so the "cover the empty fallback shape" ask is a real coverage gap, not just belt-and-braces.OptionalDecimalStringSchemais the right primitive here.Adjacent, pre-existing, not this PR:
first_entry_athas the same hole —formatUTC(v1_combos.go:263) returns""for a NULLfirst_entry_at, andIsoDateTimeStringSchemabrands without validating, so""becomes anIsoDateTimeString.Slack discussion