Skip to content

fix(jsm): accept the numeric pagination the JSM tools actually send - #6386

Merged
waleedlatif1 merged 3 commits into
stagingfrom
worktree-jsm-get-comments-validation
Aug 7, 2026
Merged

fix(jsm): accept the numeric pagination the JSM tools actually send#6386
waleedlatif1 merged 3 commits into
stagingfrom
worktree-jsm-get-comments-validation

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

JSM pagination (the main fix)

  • Every JSM tool declares start/limit as type: 'number', and the block coerces Max Results with Number.parseInt — but all 11 /api/tools/jsm/* contracts typed them as z.string(). Any JSM read with pagination filled in 400'd at Sim's own boundary before reaching Atlassian.
  • jsm_get_queues was broken unconditionally: the block always sends includeCount as a boolean (params.includeCount === 'true') and the contract demanded a string.
  • Contracts now accept both shapes and normalize to the string the routes feed into URLSearchParams. The string branch stays unconstrained so every body that parsed before still parses; the newly accepted number branch is bounded to the non-negative int32 range Atlassian documents.
  • Added the missing Start Index block input — pagination was previously impossible from the block, since only limit was wired and start was exposed nowhere.
  • Routed Max Results through the existing toOptionalInt helper so a non-numeric entry drops the param instead of sending NaN.

Verified against Atlassian's JSM Cloud OpenAPI spec: start/limit are int32 and includeCount is a boolean on all 11 endpoints, and the param names match what the routes send.

Fork mapping picker (bundled)

  • Widen the fork sync target picker from 320px to 380px; 320px still clipped the longest secret keys it lists.

Type of Change

  • Bug fix

Testing

  • New jsm.test.ts covers the contract boundary; new jira_service_management.test.ts walks the real chain (block tools.config.params → tool request.body → route contract) for all 11 paginated operations.
  • Both suites were confirmed to fail against the pre-fix contract (13 failures each) and pass after.
  • bun run lint, check:api-validation, tool-metadata:generate, generate-docs, and integration-catalog:check all clean with no drift. Docs already published start/limit as number, so this aligns the validator with the published schema rather than the reverse.
  • Confirmed backwards compatible: the serializer keeps advanced-mode subblock values that already hold data, so moving Max Results to advanced does not drop it from existing workflows.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The JSM tools declare start/limit as type: 'number' and the block coerces
Max Results with Number.parseInt, but every /api/tools/jsm/* contract typed
them as z.string(). Any JSM read with pagination filled in 400'd before
reaching Atlassian, and get_queues 400'd unconditionally because the block
always sends includeCount as a boolean.

Normalize both shapes at the contract boundary, add the missing Start Index
block input, and route Max Results through the existing toOptionalInt helper
so a non-numeric entry no longer sends NaN.
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 7, 2026 7:34pm

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are localized to JSM API validation and block param mapping with broad test coverage; string pagination behavior is preserved for backward compatibility. The fork UI tweak is cosmetic.

Overview
Fixes Jira Service Management reads that failed at Sim’s API boundary when pagination was used: tools and the block send start/limit as numbers, but route contracts only accepted strings, so requests 400’d before Atlassian. get_queues also broke because the block sends includeCount as a boolean while the contract expected a string.

Contracts (jsm.ts) now accept numbers or strings for pagination and boolean flags, normalize to strings for query params, and bound numeric pagination to non-negative int32. Block adds Start Index, wires start on all 11 paginated operations via toOptionalInt (avoids NaN), and centralizes paginated operation lists. Tests cover the contract boundary and the full block → tool → contract chain.

Also widens the fork sync mapping target picker from 320px to 380px so long secret keys aren’t clipped.

Reviewed by Cursor Bugbot for commit b000382. Configure here.

320px still clipped the longest secret keys the picker shows.
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR aligns JSM route contracts with the numeric pagination and boolean values emitted by tools while preserving existing string callers.

  • Adds bounded numeric-to-string normalization for JSM pagination fields and boolean normalization for queue counts.
  • Adds Start Index wiring and safer optional integer coercion across all paginated JSM block operations.
  • Adds contract and end-to-end block/tool/schema coverage for the affected operations.
  • Widens the fork-mapping target picker to prevent long secret labels from being clipped.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/api/contracts/selectors/jsm.ts Adds bounded numeric pagination and boolean normalization consistently across JSM route contracts.
apps/sim/lib/api/contracts/selectors/jsm.test.ts Covers numeric and legacy string pagination, int32 boundaries, omission, and queue boolean normalization.
apps/sim/blocks/blocks/jira_service_management.ts Exposes Start Index and consistently maps optional pagination inputs across all eleven supported operations.
apps/sim/ee/workspace-forking/components/fork-sync/fork-sync-view.tsx Widens the mapping target picker from 320px to 380px.
apps/sim/blocks/blocks/jira_service_management.test.ts Exercises operation resolution and the block-to-tool-to-contract pagination chain for all supported operations.

Sequence Diagram

sequenceDiagram
  participant Block as JSM Block
  participant Tool as JSM Tool
  participant Contract as Route Contract
  participant Route as API Route
  participant Atlassian as Atlassian JSM
  Block->>Tool: start/limit as numbers
  Tool->>Contract: request body
  Contract->>Contract: validate int32 and normalize to strings
  Contract->>Route: parsed start/limit
  Route->>Atlassian: URLSearchParams
Loading

Reviews (2): Last reviewed commit: "fix(jsm): cap pagination at the document..." | Re-trigger Greptile

Comment thread apps/sim/lib/api/contracts/selectors/jsm.ts Outdated
Comment thread apps/sim/blocks/blocks/jira_service_management.test.ts
Addresses review: the schema claimed the int32 range but only floored at 0,
so values above 2147483647 were forwarded to Atlassian instead of being
rejected at Sim's boundary. Also restores the const tuple for the paginated
operation list and drops the widened ToolConfig from the test table.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b000382. Configure here.

@waleedlatif1
waleedlatif1 merged commit c9aed7a into staging Aug 7, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-jsm-get-comments-validation branch August 7, 2026 19:40
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