Skip to content

Commit 5f3d4b6

Browse files
committed
fix(workspaces): count members before the rename so a failed count never hides a committed update
1 parent 8d8e618 commit 5f3d4b6

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎apps/sim/lib/workspaces/application/update-workspace.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ export const updateWorkspaceIdentity = defineAuthorizedWorkspaceUseCase({
9898
const parsed = workspaceIdentityPatchSchema.safeParse(input.patch)
9999
if (!parsed.success) throw new OrchestrationError('validation', parsed.error.issues[0].message)
100100
const patch = { name: parsed.data.name, logoUrl: parsed.data.logoUrl }
101-
const [result, memberCount] = await Promise.all([
102-
applyWorkspaceUpdate(context.workspaceId, patch),
103-
countPublicWorkspaceMembers({
104-
id: context.workspaceId,
105-
organizationId: context.workspaceOrganizationId,
106-
}),
107-
])
101+
// Counted before the write, never after or alongside it: a failed count
102+
// after the commit would report a persisted rename as failed and skip its
103+
// audit. A rename does not change membership, so the earlier count holds.
104+
const memberCount = await countPublicWorkspaceMembers({
105+
id: context.workspaceId,
106+
organizationId: context.workspaceOrganizationId,
107+
})
108+
const result = await applyWorkspaceUpdate(context.workspaceId, patch)
108109
const { id, name, color, logoUrl, createdAt, updatedAt } = result.updated
109110
return {
110111
...result,

0 commit comments

Comments
 (0)