{"record":{"id":"57d3a0162d3f2cec","repo":"actualbudget/actual","slug":"provided-account-id-is-not-linked-to-given-requisi","errorCode":null,"errorMessage":"Provided account id is not linked to given requisition","messagePattern":"Provided account id is not linked to given requisition","errorType":"exception","errorClass":"AccountNotLinkedToRequisition","httpStatus":null,"severity":"error","filePath":"packages/sync-server/src/app-gocardless/services/gocardless-service.ts","lineNumber":216,"sourceCode":"    requisitionId: GoCardlessRequisitionId,\n    accountId: GoCardlessAccountId,\n    startDate: string | undefined,\n    endDate: string | undefined,\n  ): Promise<{\n    balances: Balance[];\n    institutionId: GoCardlessInstitutionId;\n    startingBalance: number;\n    transactions: {\n      booked: Transaction[];\n      pending: Transaction[];\n      all: TransactionWithBookedStatus[];\n    };\n  }> => {\n    const { institution_id, accounts: accountIds } =\n      await goCardlessService.getLinkedRequisition(requisitionId);\n\n    if (!accountIds.includes(accountId)) {\n      throw new AccountNotLinkedToRequisition(accountId, requisitionId);\n    }\n\n    const [normalizedTransactions, accountBalance] = await Promise.all([\n      goCardlessService.getNormalizedTransactions(\n        requisitionId,\n        accountId,\n        startDate,\n        endDate,\n      ),\n      goCardlessService.getBalances(accountId),\n    ]);\n\n    const transactions = normalizedTransactions.transactions;\n\n    const bank: IBank = BankFactory(institution_id);\n\n    const startingBalance = bank.calculateStartingBalance(\n      transactions.booked,","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/sync-server/src/app-gocardless/services/gocardless-service.ts#L198-L234","documentation":"In getTransactionsWithBalance, the sync-server first loads the GoCardless requisition (a bank link/session) via getLinkedRequisition and reads the list of account ids it contains. If the accountId requested for transactions+balance is not one of the accounts in that requisition, it throws AccountNotLinkedToRequisition. This guard prevents querying GoCardless for an account that was never part of the bank connection, which would fail at the API anyway.","triggerScenarios":"Calling goCardlessService.getTransactionsWithBalance(requisitionId, accountId, ...) where accountId is not present in the `accounts` array returned by getLinkedRequisition(requisitionId) — e.g. pairing an account id from a different bank link, or a stale/renumbered account id after a re-link.","commonSituations":"Bank connections were re-established and the old requisition now links a new set of account ids while the budget still references the old account; a copy/paste mistake mixing ids across two GoCardless bank connections; a deleted or revoked requisition replaced by a new one with different account ids.","solutions":["Verify the accountId belongs to the requisition: GET the requisition's linked accounts and use one of those ids.","Re-run the bank link flow (accounts list step) so the budget's account mappings match the current requisition's accounts.","If the bank added/replaced accounts after linking, delete and re-create the GoCardless link in Actual so account ids are refreshed.","Check for a typo or mixed-up requisitionId/accountId pair when calling the API directly."],"exampleFix":"// before\nawait goCardlessService.getTransactionsWithBalance('req-ABC', 'acct-XYZ', start, end);\n\n// after\nconst { accounts } = await goCardlessService.getLinkedRequisition('req-ABC');\nif (!accounts.includes('acct-XYZ')) {\n  throw new Error(`acct-XYZ not in req-ABC; available: ${accounts.join(',')}`);\n}\nawait goCardlessService.getTransactionsWithBalance('req-ABC', 'acct-XYZ', start, end);","handlingStrategy":"validation","validationCode":"const { accounts } = await goCardlessService.getLinkedRequisition(requisitionId);\nif (!accounts.includes(accountId)) {\n  throw new Error(`account ${accountId} not linked to requisition ${requisitionId}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve account ids from getLinkedRequisition rather than storing ids long-term.","After re-linking a bank, refresh all stored requisition/account id pairs.","Log both ids on mismatch to catch cross-connection mix-ups early."],"tags":["gocardless","bank-sync","configuration"],"backgroundTag":"account-not-linked-to-requisition","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}