Skip to content

Commit 6f01b80

Browse files
committed
fix(organizations): read owned credentials before account statuses on Home widgets
Owned credentials exclude one awaiting reconnection. Read in parallel, a concurrent read that refused a token could drop an account from the owned set after its status read 'active', and the widget reported it as not offered instead of asking to reconnect.
1 parent 7614846 commit 6f01b80

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎apps/sim/lib/organizations/application/home-widgets.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,14 @@ async function readViewerAccounts<T>(
133133
throw new OrchestrationError('forbidden', 'Integrations are not available to you here')
134134
// The boundary the assistant's direct tools answer to, which a widget must not sidestep. Read
135135
// fresh on each widget read, so a revoked approval or a tightened policy applies on the next one.
136-
const [accounts, owned, isProviderContentReadable] = await Promise.all([
137-
listViewerOrganizationAccounts({ organizationId, userId }),
136+
const [owned, isProviderContentReadable] = await Promise.all([
138137
getOwnOrganizationManagedOAuthCredentials({ organizationId, userId }),
139138
loadAssistantProviderAccess(organizationId),
140139
])
140+
// Owned credentials exclude one awaiting reconnection, so statuses are read after them: a
141+
// concurrent read that marks one `needs_reauth` in between shows here as needing reconnection,
142+
// never as an account not offered.
143+
const accounts = await listViewerOrganizationAccounts({ organizationId, userId })
141144
const candidates = accounts
142145
.flatMap((account) => {
143146
const provider = findCredentialGroupProviderFromProviderId(account.providerId)

0 commit comments

Comments
 (0)