fix: delete AppConnect's token variable when linking its account fails, so Save can be retried

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-10-19 12:56:26 +02:00
co-authored by Claude Opus 5.5
parent b4d0b9fe69
commit a88eff801c
2 changed files with 16 additions and 6 deletions
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT EXISTS(SELECT 1 FROM variable WHERE account = $1 AND workspace_id = $2)",
"query": "SELECT EXISTS(SELECT 1 FROM variable WHERE account = $1 AND workspace_id = $2 AND path <> $3)",
"describe": {
"columns": [
{
@@ -12,6 +12,7 @@
"parameters": {
"Left": [
"Int4",
"Text",
"Text"
]
},
@@ -19,5 +20,5 @@
null
]
},
"hash": "7aa589db3199d7f727cc69e63e1281b7ed329ff0c9d1617747f4ccd6014720cf"
"hash": "92d2202c8752ab24777daa5c46b14ae645076a85940cef890083a45301a7cd62"
}
@@ -1005,10 +1005,19 @@
}
})
if (accountData) {
await OauthService.createAccount({
workspace: effectiveWorkspace,
requestBody: { ...accountData, variable_path: tokenPath }
})
try {
await OauthService.createAccount({
workspace: effectiveWorkspace,
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(() => {})
throw e
}
}
resourceValue['token'] = `$var:${tokenPath}`
}