Skip to content

fix(connect): Serialize pagination options for auto-pagination#1601

Merged
gjtorikian merged 2 commits into
mainfrom
fix-pagination-bug
Jun 2, 2026
Merged

fix(connect): Serialize pagination options for auto-pagination#1601
gjtorikian merged 2 commits into
mainfrom
fix-pagination-bug

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

@gjtorikian gjtorikian commented Jun 1, 2026

Summary

Test plan

  • await workos.connect.listApplications({ organizationId: '...' }).then(r => r.autoPagination()) no longer throws 422
  • bash scripts/ci passes

Fixes #1600

`listApplications` passed raw camelCase options to
`AutoPaginatable`, so `generatePages` sent `organizationId`
instead of `organization_id` on re-fetch — the API rejected
it with a 422. Same regression as #1459, reintroduced when
the Connect module was generated.

Fixes #1600
@gjtorikian gjtorikian requested review from a team as code owners June 1, 2026 19:57
@gjtorikian gjtorikian requested a review from robertLichtnow June 1, 2026 19:57
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR fixes a regression where listApplications passed raw camelCase options (organizationId) to AutoPaginatable, causing subsequent page fetches to send organizationId instead of organization_id and receive 422 errors from the API. The fix serializes options to snake_case before constructing the AutoPaginatable instance.

  • serializeListApplicationsOptions is now called before passing options to AutoPaginatable, so generatePages spreads organization_id (not organizationId) into each re-fetch call.
  • The return type was widened to AutoPaginatable<ConnectApplication, PaginationOptions> since the stored options are now the serialized wire shape, not the original camelCase ListApplicationsOptions.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-scoped fix that correctly serializes filter options before they reach the auto-pagination layer.

The only change is calling serializeListApplicationsOptions before constructing AutoPaginatable, mirroring the identical fix applied to other modules. The initial fetch already serialized options correctly; the bug was only on re-fetches inside generatePages, which spread this.options directly into query params. The fix is consistent with the established pattern in the codebase and does not touch any other code paths.

No files require special attention.

Important Files Changed

Filename Overview
src/connect/connect.ts Serializes ListApplicationsOptions before passing to AutoPaginatable, fixing 422 errors on auto-paginated re-fetches; return type updated to match the runtime wire shape.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant listApplications
    participant AutoPaginatable
    participant API

    Caller->>listApplications: "listApplications({ organizationId: "org_123" })"
    Note over listApplications: serializeListApplicationsOptions()<br/>{ organization_id: "org_123" }
    listApplications->>API: "GET /connect/applications?organization_id=org_123"
    API-->>listApplications: page 1 + listMetadata.after
    listApplications->>AutoPaginatable: "new AutoPaginatable(page1, fetchFn, { organization_id: "org_123" })"
    AutoPaginatable-->>Caller: result

    Caller->>AutoPaginatable: .autoPagination()
    loop while listMetadata.after exists
        AutoPaginatable->>API: "GET /connect/applications?organization_id=org_123&limit=100&after=cursor"
        API-->>AutoPaginatable: next page
    end
    AutoPaginatable-->>Caller: all results
Loading

Reviews (2): Last reviewed commit: "appease greptile" | Re-trigger Greptile

Comment thread src/connect/connect.ts
@gjtorikian gjtorikian merged commit c8333f4 into main Jun 2, 2026
7 checks passed
@gjtorikian gjtorikian deleted the fix-pagination-bug branch June 2, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

connect.listApplications auto-pagination sends unserialized organizationId → 422 (regression of #1459)

2 participants