fix: keep the resource AppConnect fills when linking its account fails

Deleting a variable also deletes the resource at its path, so the rollback
is skipped when filling an existing resource.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-10-20 10:17:36 +02:00
co-authored by Claude Opus 5.5
parent b8f7849a7d
commit bf40abe638
@@ -1011,11 +1011,14 @@
requestBody: { ...accountData, variable_path: tokenPath }
})
} catch (e) {
// An unlinked token never refreshes, and its path would block a retry.
await VariableService.deleteVariable({
workspace: effectiveWorkspace,
path: tokenPath
}).catch(() => {})
// An unlinked token never refreshes, and its path would block a retry. Not when
// filling: deleting a variable also deletes the resource at its path.
if (!filling) {
await VariableService.deleteVariable({
workspace: effectiveWorkspace,
path: tokenPath
}).catch(() => {})
}
throw e
}
}