fix: argument forwarding in vault.listObjects#1517
Open
rodobre wants to merge 1 commit intoworkos:mainfrom
Open
fix: argument forwarding in vault.listObjects#1517rodobre wants to merge 1 commit intoworkos:mainfrom
vault.listObjects#1517rodobre wants to merge 1 commit intoworkos:mainfrom
Conversation
Contributor
Greptile SummaryThis PR fixes a bug in
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
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>
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); | ||
| } |
Contributor
There was a problem hiding this comment.
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');
});
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related issue
#1516
Description
vault.listObjectsacceptsPaginationOptionsbut only forwardsafterandlimitto the API. Thebeforeandorderparameters are silently ignored, making it impossible to paginate backwards or control sort order through the SDK.This adds the missing
beforeandorderquery parameters to the vaultlistObjectsmethod, matching how other endpoints (e.g.sso.listConnections,organizations.listOrganizations) already handle pagination.Changes
options.beforeas thebeforequery parameteroptions.orderas theorderquery parameterBefore
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());
}
//
beforeandordernever reach the APIDocumentation
No documentation change is required.