From 3daf74ea6e6cb2949159634eda64ea46487ac0e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Jul 2026 17:02:40 +0000 Subject: [PATCH] fix: pass query params to delete requests correctly WorkOS#delete takes the query object bare as its second argument, unlike get/post/put which take { query: {...} }. Two callers passed the wrapped shape, so URLSearchParams stringified the nested object and the request carried ?query=[object Object] instead of the real params: - pipes.deleteUserConnectedAccount dropped organization_id - vault.deleteObject dropped version_check Pass the query objects bare, tighten WorkOS#delete's query parameter from any to a flat record type so the wrapped shape no longer typechecks, and assert the actual query strings in both specs. Fixes #1667 --- src/pipes/pipes.spec.ts | 4 ++++ src/pipes/pipes.ts | 8 +++----- src/vault/vault.spec.ts | 4 ++++ src/vault/vault.ts | 8 +++----- src/workos.ts | 5 ++++- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/pipes/pipes.spec.ts b/src/pipes/pipes.spec.ts index 944e58bfd..bc8d96c93 100644 --- a/src/pipes/pipes.spec.ts +++ b/src/pipes/pipes.spec.ts @@ -308,6 +308,10 @@ describe('Pipes', () => { expect(new URL(String(fetchURL())).pathname).toBe( '/user_management/users/test_userId/connected_accounts/test_slug', ); + expect(fetchSearchParams()).toEqual({ + organization_id: 'org_01EHZNVPK3SFK441A1RGBFSHRT', + }); + expect(fetchSearchParams()).not.toHaveProperty('query'); }); }); diff --git a/src/pipes/pipes.ts b/src/pipes/pipes.ts index dccd265e7..eeadae230 100644 --- a/src/pipes/pipes.ts +++ b/src/pipes/pipes.ts @@ -477,11 +477,9 @@ export class Pipes { await this.workos.delete( `/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, { - query: { - ...(options.organizationId !== undefined && { - organization_id: options.organizationId, - }), - }, + ...(options.organizationId !== undefined && { + organization_id: options.organizationId, + }), }, ); } diff --git a/src/vault/vault.spec.ts b/src/vault/vault.spec.ts index 9c7fac444..8903e7200 100644 --- a/src/vault/vault.spec.ts +++ b/src/vault/vault.spec.ts @@ -201,6 +201,10 @@ describe('Vault', () => { expect(fetchMethod()).toBe('DELETE'); expect(new URL(String(fetchURL())).pathname).toBe('/vault/v1/kv/test_id'); + expect(fetchSearchParams()).toEqual({ + version_check: 'test_version_check', + }); + expect(fetchSearchParams()).not.toHaveProperty('query'); }); }); diff --git a/src/vault/vault.ts b/src/vault/vault.ts index dafc1eae9..0c0da6d9e 100644 --- a/src/vault/vault.ts +++ b/src/vault/vault.ts @@ -305,11 +305,9 @@ export class Vault { async deleteObject(options: DeleteVaultObjectOptions): Promise { const { id } = options; await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, { - query: { - ...(options.versionCheck !== undefined && { - version_check: options.versionCheck, - }), - }, + ...(options.versionCheck !== undefined && { + version_check: options.versionCheck, + }), }); } diff --git a/src/workos.ts b/src/workos.ts index 82ce3ba30..6f5c12bb8 100644 --- a/src/workos.ts +++ b/src/workos.ts @@ -358,7 +358,10 @@ export class WorkOS { return { data: await res.toJSON() }; } - async delete(path: string, query?: any): Promise { + async delete( + path: string, + query?: Record, + ): Promise { this.requireApiKey(path); try {