{"record":{"id":"a8b756d52bec5304","repo":"actualbudget/actual","slug":"account-with-id-upgradingid-not-found","errorCode":null,"errorMessage":"Account with ID ${upgradingId} not found.","messagePattern":"Account with ID (.+?) not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/accounts/app.ts","lineNumber":190,"sourceCode":"  upgradingId,\n  offBudget = false,\n  startingDate,\n  startingBalance,\n}: LinkAccountBaseParams & {\n  requisitionId: string;\n  account: SyncServerGoCardlessAccount;\n}) {\n  let id;\n  const bank = await link.findOrCreateBank(account.institution, requisitionId);\n\n  if (upgradingId) {\n    const accRow = await db.first<db.DbAccount>(\n      'SELECT * FROM accounts WHERE id = ?',\n      [upgradingId],\n    );\n\n    if (!accRow) {\n      throw new Error(`Account with ID ${upgradingId} not found.`);\n    }\n\n    id = accRow.id;\n    await db.update('accounts', {\n      id,\n      account_id: account.account_id,\n      bank: bank.id,\n      account_sync_source: 'goCardless',\n    });\n  } else {\n    id = uuidv4();\n    await db.insertWithUUID('accounts', {\n      id,\n      account_id: account.account_id,\n      mask: account.mask,\n      name: account.name,\n      official_name: account.official_name,\n      bank: bank.id,","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/accounts/app.ts#L172-L208","documentation":"When linking a GoCardless (Nordigen) bank account to upgrade an existing (off-budget/manual) account, Actual looks up the account row by the provided upgradingId. This error is thrown when no accounts row exists for that id, meaning the client referenced an account that no longer exists in the budget database.","triggerScenarios":"Calling the 'gocardless-link-account' (linkGoCardlessAccount) handler with an upgradingId that was deleted, belongs to a different budget file, or was never persisted (stale client state).","commonSituations":"The user deleted the manual account in another tab/device before finishing the link flow; a stale sync left the UI showing a nonexistent account; the client sent an id from a different budget.","solutions":["Refresh the account list and re-run the bank-link flow, selecting the account again so a fresh id is sent.","Verify the id exists: run a query 'SELECT * FROM accounts WHERE id = ?' with the id before linking.","Re-sync the budget on the affected device so local state matches the server, then retry.","If the account was deleted intentionally, create a new manual account and link the bank account to that instead."],"exampleFix":"// before\nawait send('gocardless-link-account', {\n  upgradingId: staleAccountId,\n  ...rest,\n});\n\n// after\nconst acc = await q('SELECT id FROM accounts WHERE id = ?', [staleAccountId]);\nif (!acc) {\n  console.warn('Account no longer exists; linking as a new account instead');\n}\nawait send('gocardless-link-account', { upgradingId: acc ? staleAccountId : null, ...rest });","handlingStrategy":"validation","validationCode":"const acc = await db.first('SELECT id FROM accounts WHERE id = ?', [upgradingId]);\nif (!acc) {\n  throw new Error(`Refusing to link: account ${upgradingId} does not exist`);\n}","typeGuard":"async function accountExists(id: string): Promise<boolean> {\n  return !!(await db.first('SELECT id FROM accounts WHERE id = ?', [id]));\n}","tryCatchPattern":"try {\n  await send('gocardless-link-account', { upgradingId, ...rest });\n} catch (e) {\n  if (/Account with ID .* not found/.test(e.message)) {\n    await refreshAccounts(); // re-run flow with fresh ids\n  } else throw e;\n}","preventionTips":["Always re-fetch account ids from the current budget state before bank-link operations.","Avoid caching account ids across budget switches or reloads.","Sync devices before performing bank-link upgrades."],"tags":["bank-sync","gocardless","missing-record","validation"],"backgroundTag":"record-not-found","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}