Skip to content

fix: argument forwarding in vault.listObjects#1517

Open
rodobre wants to merge 1 commit intoworkos:mainfrom
rodobre:fix/issue-1516/vault-listobjects-parameters
Open

fix: argument forwarding in vault.listObjects#1517
rodobre wants to merge 1 commit intoworkos:mainfrom
rodobre:fix/issue-1516/vault-listobjects-parameters

Conversation

@rodobre
Copy link

@rodobre rodobre commented Mar 11, 2026

Related issue

#1516

Description

vault.listObjects accepts PaginationOptions but only forwards after and limit to the API. The before and order parameters are silently ignored, making it impossible to paginate backwards or control sort order through the SDK.

This adds the missing before and order query parameters to the vault listObjects method, matching how other endpoints (e.g. sso.listConnections, organizations.listOrganizations) already handle pagination.

Changes

  • Forward options.before as the before query parameter
  • Forward options.order as the order query parameter

Before

const url = new URL('/vault/v1/kv', this.workos.baseURL);
if (options?.after) {
url.searchParams.set('after', options.after);
}
if (options?.limit) {
url.searchParams.set('limit', options.limit.toString());
}
// before and order never reach the API

Documentation

No documentation change is required.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR fixes a bug in vault.listObjects where before and order pagination parameters accepted by the method's PaginationOptions argument were silently dropped and never forwarded to the API. The fix mirrors the approach already used by after and limit in the same method, and matches the pattern seen in the shared serializePaginationOptions helper and other SDK endpoints.

  • Root cause fixed: before and order are now appended as URL query parameters, consistent with how after and limit are handled.
  • Null/undefined safety: The truthy guard (if (options?.before)) correctly suppresses null and undefined values, matching the existing after behaviour and the shared serializer.
  • No breaking changes: Existing callers that omit these options are unaffected.
  • Test gap: vault.spec.ts has no test cases exercising the newly forwarded parameters; adding coverage would prevent regressions.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, additive bug fix with no breaking changes.
  • The change is two short, symmetric blocks that follow exactly the same pattern as the pre-existing after and limit handling in the same function. The PaginationOptions interface already declares before and order, so no type changes are needed. The only gap is missing unit-test coverage for the new parameters.
  • No files require special attention; src/vault/vault.spec.ts would benefit from additional test cases for the new parameters.

Important Files Changed

Filename Overview
src/vault/vault.ts Adds before and order query parameters to listObjects, fixing silent omission. Implementation is consistent with the existing after/limit pattern and the shared serializePaginationOptions helper.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant vault.listObjects
    participant WorkOS API

    Caller->>vault.listObjects: listObjects({ before, after, limit, order })
    Note over vault.listObjects: Build URL /vault/v1/kv
    vault.listObjects->>vault.listObjects: set ?before= (new)
    vault.listObjects->>vault.listObjects: set ?after=
    vault.listObjects->>vault.listObjects: set ?limit=
    vault.listObjects->>vault.listObjects: set ?order= (new)
    vault.listObjects->>WorkOS API: GET /vault/v1/kv?before=&after=&limit=&order=
    WorkOS API-->>vault.listObjects: ListResponse<ObjectDigestResponse>
    vault.listObjects-->>Caller: List<ObjectDigest>
Loading

Last reviewed commit: 8281d91

Comment on lines +88 to +99
if (options?.before) {
url.searchParams.set('before', options.before);
}
if (options?.after) {
url.searchParams.set('after', options.after);
}
if (options?.limit) {
url.searchParams.set('limit', options.limit.toString());
}
if (options?.order) {
url.searchParams.set('order', options.order);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test coverage for new parameters

The existing listObjects test suite only covers the no-options case. The newly forwarded before and order parameters have no corresponding test cases to verify they are correctly appended as query parameters. Consider adding tests similar to:

it('forwards before and order query parameters', async () => {
  fetchOnce({ data: [], list_metadata: { after: null, before: null } });
  await workos.vault.listObjects({ before: 'cursor123', order: 'asc' });
  expect(fetchURL()).toContain('before=cursor123');
  expect(fetchURL()).toContain('order=asc');
});

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.

1 participant