Skip to content

fix(sdk): validate positive numeric round IDs (#256) - #345

Merged
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
emrekayat:fix/assigned-256
Sep 8, 2026
Merged

fix(sdk): validate positive numeric round IDs (#256)#345
karagozemin merged 1 commit into
Sub-Rosa-Issue:mainfrom
emrekayat:fix/assigned-256

Conversation

@emrekayat

Copy link
Copy Markdown
Contributor

Closes #256.

Rejects zero/negative bigint IDs and unsafe, fractional or non-finite numeric IDs before conversion. Keeps arbitrary-precision positive bigint and string inputs intact.

Validation: SDK suite: 197 tests pass; SDK typecheck passes on the combined verification branch.

Copilot AI lite review requested due to automatic review settings September 8, 2026 17:13
@karagozemin
karagozemin merged commit b09ea0d into Sub-Rosa-Issue:main Sep 8, 2026
2 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The functional changes align with the stated acceptance criteria, and the remaining feedback is limited to minor test naming and error-message clarity improvements.

Pull request overview

This PR tightens normalizeRoundId’s input validation so round IDs consistently follow a positive-integer contract across bigint and number inputs (matching the existing string behavior), aligning the SDK with issue #256’s requirements.

Changes:

  • Rejects bigint round IDs that are 0n or negative.
  • Rejects number round IDs that are non-finite, fractional, unsafe, zero, or negative before converting to bigint.
  • Adds boundary-focused tests covering invalid numeric/bigint inputs and ensuring valid inputs remain unchanged.
File summaries
File Description
packages/sdk/src/ids.ts Adds validation for bigint and strengthens number validation to positive safe integers before BigInt conversion.
packages/sdk/src/ids.test.ts Adds boundary tests asserting rejection of invalid numeric/bigint inputs and preservation of valid ones.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +41 to +45
for (const value of [0, -0, -1, 1.5, NaN, Infinity, -Infinity, Number.MAX_SAFE_INTEGER + 1, 0n, -1n]) {
it(`rejects ${String(value)} (${typeof value})`, () => {
assert.throws(() => normalizeRoundId(value), /roundId must be a positive/);
});
}
Comment thread packages/sdk/src/ids.ts
Comment on lines +16 to 18
if (!Number.isSafeInteger(value) || value < 1) {
throw new Error(`roundId must be a positive safe integer, got ${JSON.stringify(value)}`);
}
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.

fix(sdk): validate numeric and bigint round IDs consistently

3 participants