{"record":{"id":"ad25cbe83200fb4f","repo":"actualbudget/actual","slug":"bank-with-id-bankid-not-found","errorCode":null,"errorMessage":"Bank with ID ${bankId} not found.","messagePattern":"Bank with ID (.+?) not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/loot-core/src/server/accounts/app.ts","lineNumber":1741,"sourceCode":"    'SELECT COUNT(*) as count FROM accounts WHERE bank = ?',\n    [bankId],\n  );\n\n  // No more accounts are associated with this bank. We can remove\n  // it from GoCardless.\n  const userToken = await asyncStorage.getItem('user-token');\n  if (!userToken) {\n    return 'ok';\n  }\n\n  if (!accountWithBankResult || accountWithBankResult.count === 0) {\n    const bank = await db.first<Pick<db.DbBank, 'bank_id'>>(\n      'SELECT bank_id FROM banks WHERE id = ?',\n      [bankId],\n    );\n\n    if (!bank) {\n      throw new Error(`Bank with ID ${bankId} not found.`);\n    }\n\n    const serverConfig = getServer();\n    if (!serverConfig) {\n      throw new Error('Failed to get server config.');\n    }\n\n    const requisitionId = bank.bank_id;\n\n    try {\n      await post(\n        serverConfig.GOCARDLESS_SERVER + '/remove-account',\n        {\n          requisitionId,\n        },\n        {\n          'X-ACTUAL-TOKEN': userToken,\n        },","sourceCodeStart":1723,"sourceCodeEnd":1759,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/loot-core/src/server/accounts/app.ts#L1723-L1759","documentation":"Actual looks up the bank (GoCardless/Nordigen institution link) row by its ID before performing a bank-side operation such as creating a requisition. If no row in the `banks` table matches the given bankId, the app cannot proceed and throws this error. It means the caller passed a bank ID that does not exist in this budget's database.","triggerScenarios":"Calling the bank-sync internals (via API or a stale UI client) with a bankId that was deleted, belongs to a different budget file, or was never created. Also happens with a migrated/restored budget where the `banks` row was removed but old references remain.","commonSituations":"Restoring an old budget file after re-linking the bank; switching sync-server instances or GoCardless accounts; using the API with an ID copied from another budget; the bank having been unlinked previously.","solutions":["Verify the bankId exists for this budget (SELECT id FROM banks) or re-list linked banks in the UI; use a current ID.","Re-link the bank in Settings > Bank sync to create a fresh bank row, then retry.","If migrating budgets, re-authenticate the bank in the new budget instead of copying IDs across.","Remove or update stale client caches/references to deleted bank IDs."],"exampleFix":"// before\nawait crinx.getOrCreateRequisition('9f3c-...deleted-bank-id...');\n// after\nconst banks = await listUserBanks(); // confirm a valid id first\nawait crinx.getOrCreateRequisition(banks[0].bank_id);","handlingStrategy":"validation","validationCode":"const bank = await db.first('SELECT bank_id FROM banks WHERE id = ?', [bankId]);\nif (!bank) throw new Error(`Skipping: bank ${bankId} does not exist in this budget`);","typeGuard":"function isBank(v: { bank_id: string } | null | undefined): v is { bank_id: string } {\n  return v != null && typeof v.bank_id === 'string';\n}","tryCatchPattern":"try {\n  await syncBank(bankId);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Bank with ID')) {\n    // bank no longer exists: re-link the bank before retrying\n    return;\n  }\n  throw e;\n}","preventionTips":["Always fetch the current bank list from the budget before referencing a bankId.","Never copy bank IDs between budgets or environments.","Re-link banks after restoring/migrating a budget file instead of reusing old IDs.","Check the banks table when debugging stale references."],"tags":["bank-sync","database","invalid-id"],"backgroundTag":"resource-not-found-by-id","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}