{"record":{"id":"dd191691392b8d96","repo":"actualbudget/actual","slug":"account-with-id-this-props-accountid-not-found","errorCode":null,"errorMessage":"Account with ID ${this.props.accountId} not found.","messagePattern":"Account with ID (.+?) not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop-client/src/components/accounts/Account.tsx","lineNumber":801,"sourceCode":"\n  onAddTransaction = () => {\n    this.setState({ isAdding: true });\n  };\n\n  onSaveName = (name: string) => {\n    const accountNameError = validateAccountName(\n      name,\n      this.props.accountId ?? '',\n      this.props.accounts,\n    );\n    if (accountNameError) {\n      this.setState({ nameError: accountNameError });\n    } else {\n      const account = this.props.accounts.find(\n        account => account.id === this.props.accountId,\n      );\n      if (!account) {\n        throw new Error(`Account with ID ${this.props.accountId} not found.`);\n      }\n      this.props.onUpdateAccount({ ...account, name });\n      this.setState({ nameError: '' });\n    }\n  };\n\n  onToggleExtraBalances = () => {\n    this.props.setShowExtraBalances(!this.props.showExtraBalances);\n  };\n\n  onMenuSelect = async (\n    item:\n      | 'link'\n      | 'unlink'\n      | 'close'\n      | 'reopen'\n      | 'export'\n      | 'remove-sorting'","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/desktop-client/src/components/accounts/Account.tsx#L783-L819","documentation":"AccountInternal's renameAccountName handler looks up the account in the `accounts` prop by `accountId` and throws when no match exists. The component assumes its accounts list is always in sync with the accountId prop; when the list is stale/empty or the id is invalid, the rename cannot proceed and it fails fast.","triggerScenarios":"Renaming an account (submitting the rename form) while the `accounts` prop no longer contains the account: the account was deleted in another view/tab, the list hasn't loaded yet, or accountId points to a closed/off-balance account filtered out of `accounts`.","commonSituations":"Deleting an account from a second browser tab then renaming it in the first; race where the account list query is still loading; navigating to a stale deep-link /accounts/<deleted-id> and editing the name.","solutions":["Ensure the accounts list is loaded before rendering the editable name field (gate on accounts.length / loading state).","Look the account up from the server store by id (e.g. via the entity/query layer) instead of only the `accounts` prop, so closed/filtered accounts still resolve.","Return a validation error ('Account not found') to the UI instead of throwing, and clear the stale id by redirecting to the accounts page."],"exampleFix":"// before\nconst account = this.props.accounts.find(a => a.id === this.props.accountId);\nif (!account) throw new Error(`Account with ID ${this.props.accountId} not found.`);\n\n// after\nconst account = this.props.accounts.find(a => a.id === this.props.accountId);\nif (!account) {\n  this.setState({ nameError: 'Account not found' });\n  return;\n}","handlingStrategy":"validation","validationCode":"const account = accounts.find(a => a.id === accountId);\nif (!account) {\n  // account missing/stale — abort rename instead of throwing\n  return;\n}","typeGuard":"function isKnownAccount(accounts: AccountEntity[], accountId: string): boolean {\n  return accounts.some(a => a.id === accountId);\n}","tryCatchPattern":"try {\n  await renameAccount(accountId, newName);\n} catch (e) {\n  if (String(e.message).includes('not found')) {\n    setError('This account no longer exists.');\n  } else throw e;\n}","preventionTips":["Disable the name field until the account resolves from the accounts list.","Re-fetch/derive the account from the store by id rather than trusting a possibly filtered prop.","Listen for account-deletion events/sync updates and close open editors for removed accounts."],"tags":["react","race-condition","stale-data","accounts"],"backgroundTag":"entity-not-found","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}