fix: link the account to the token variable AppConnect created, even if the path is edited mid-save

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-10-16 11:43:20 +02:00
co-authored by Claude Opus 5.5
parent 46f1ed15c8
commit aeeecf5622
@@ -988,10 +988,13 @@
// OAuth flow: single secret variable for the token
if (typeof value == 'string' && value != '' && !value.startsWith('$var:')) {
savedVariableCount++
// Read once: the path field stays editable while this awaits, and the account
// must link the variable this call created.
const tokenPath = path
await VariableService.createVariable({
workspace: effectiveWorkspace,
requestBody: {
path,
path: tokenPath,
value: value,
is_secret: true,
description: emptyString(description)
@@ -1002,13 +1005,12 @@
}
})
if (accountData) {
// Links the variable just created, so it refreshes through the account.
await OauthService.createAccount({
workspace: effectiveWorkspace,
requestBody: { ...accountData, variable_path: path }
requestBody: { ...accountData, variable_path: tokenPath }
})
}
resourceValue['token'] = `$var:${path}`
resourceValue['token'] = `$var:${tokenPath}`
}
} else if (linkedSecrets.length === 1) {
// Single secret: use the resource path as variable name (original behavior)