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-16 12:55:26 +02:00
co-authored by Claude Opus 5.5
parent 40f3f6a515
commit 01c45104fd
@@ -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
}
}