Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/delete-organization-require-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

`organizations.deleteOrganization()` now validates that an organization ID was provided. Calling it with an empty ID throws `A valid resource ID is required.` locally instead of issuing a `DELETE` request to the organizations collection endpoint, matching the other ID-based methods on the API.
6 changes: 6 additions & 0 deletions packages/backend/src/api/__tests__/OrganizationApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ describe('OrganizationAPI', () => {
});
});

describe('deleteOrganization', () => {
it('throws an error when the organization ID is missing', async () => {
await expect(apiClient.organizations.deleteOrganization('')).rejects.toThrow('A valid resource ID is required.');
});
});

describe('createOrganizationInvitationBulk', () => {
const mockInvitation = {
object: 'organization_invitation',
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/api/endpoints/OrganizationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ export class OrganizationAPI extends AbstractAPI {
}

public async deleteOrganization(organizationId: string) {
this.requireId(organizationId);

return this.request<Organization>({
method: 'DELETE',
path: joinPaths(basePath, organizationId),
Expand Down
Loading