{"record":{"id":"ddacbb96353521a0","repo":"koala73/worldmonitor","slug":"account-not-found","errorCode":"ACCOUNT_NOT_FOUND","errorMessage":"ACCOUNT_NOT_FOUND","messagePattern":"ACCOUNT_NOT_FOUND","errorType":"error_code","errorClass":"ConvexError","httpStatus":null,"severity":"error","filePath":"convex/companyMonitoring/accounts.ts","lineNumber":427,"sourceCode":"  });\n  await scheduleScopedKeyCacheInvalidation(ctx, ownerUserId);\n  await scheduleAccountPurge(ctx, ownerFenceHash, purgeGeneration);\n  return ctx.db.get(account._id);\n}\n\nexport const markOwnerDeleted = internalMutation({\n  args: { ownerUserId: v.string() },\n  handler: async (ctx, args) => terminalize(ctx, args.ownerUserId, \"owner_deleted\"),\n});\n\nexport const markAccountDeleted = internalMutation({\n  args: { ownerAccountId: v.string() },\n  handler: async (ctx, args) => {\n    const account = await ctx.db\n      .query(\"companyMonitoringAccounts\")\n      .withIndex(\"by_logicalAccountId\", (q) => q.eq(\"logicalAccountId\", args.ownerAccountId))\n      .unique();\n    if (!account || !account.ownerUserId) throw new ConvexError(\"ACCOUNT_NOT_FOUND\");\n    return terminalize(ctx, account.ownerUserId, \"account_deleted\", account);\n  },\n});\n\nexport const advanceAccountPurge = internalMutation({\n  args: { ownerFenceHash: v.string(), purgeGeneration: v.number() },\n  handler: async (ctx, args) => {\n    const account = await ctx.db\n      .query(\"companyMonitoringAccounts\")\n      .withIndex(\"by_ownerFenceHash\", (q) => q.eq(\"ownerFenceHash\", args.ownerFenceHash))\n      .unique();\n    if (!account || account.purgeGeneration !== args.purgeGeneration) return { status: \"stale\" };\n    if (account.purgePhase === \"none\" || account.purgePhase === \"complete\") {\n      return { status: \"complete\" };\n    }\n\n    const now = Date.now();\n    if (account.purgePhase === \"pending\") {","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/convex/companyMonitoring/accounts.ts#L409-L445","documentation":"Lookup failure in the markAccountDeleted internal mutation: no companyMonitoringAccounts row matched the supplied ownerAccountId via the by_logicalAccountId index. The account being deleted by logical id does not exist — already purged, never existed, or the logical id is wrong.","triggerScenarios":"Thrown at convex/companyMonitoring/accounts.ts:427 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the logicalAccountId being passed; re-resolve it from the owner's current account row","If the account was already terminalized or purged, treat deletion as already complete"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}