{"record":{"id":"b4c20bfee7e2b595","repo":"koala73/worldmonitor","slug":"company-monitoring-account-not-found","errorCode":null,"errorMessage":"COMPANY_MONITORING_ACCOUNT_NOT_FOUND","messagePattern":"COMPANY_MONITORING_ACCOUNT_NOT_FOUND","errorType":"exception","errorClass":"ConvexError","httpStatus":null,"severity":"error","filePath":"convex/companyMonitoring/claimPolicyMigration.ts","lineNumber":34,"sourceCode":" *\n * The caller threads `nextCursor` through later invocations. New writes already\n * carry the current policy, so companies created while this sequence runs do\n * not need to be captured by the legacy page walk. The account version is\n * written only after Convex reports the final company page complete.\n */\nexport const migrateAccountClaimPolicy = internalMutation({\n  args: {\n    ownerAccountId: v.string(),\n    cursor: v.optional(v.union(v.string(), v.null())),\n  },\n  handler: async (ctx, args) => {\n    const account = await ctx.db\n      .query(\"companyMonitoringAccounts\")\n      .withIndex(\"by_logicalAccountId\", (q) =>\n        q.eq(\"logicalAccountId\", args.ownerAccountId)\n      )\n      .unique();\n    if (!account) throw new ConvexError(\"COMPANY_MONITORING_ACCOUNT_NOT_FOUND\");\n    if (hasCurrentCompanyMonitoringClaimPolicy(account)) {\n      return {\n        status: \"complete\" as const,\n        companiesProcessed: 0,\n        claimsPatched: 0,\n        aliasesInserted: 0,\n        nextCursor: null,\n        claimPolicyVersion: account.claimPolicyVersion,\n      };\n    }\n\n    const page = await ctx.db\n      .query(\"companyMonitoringCompanies\")\n      .withIndex(\"by_account_companyId\", (q) =>\n        q.eq(\"ownerAccountId\", args.ownerAccountId)\n      )\n      .paginate({\n        cursor: args.cursor ?? null,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/koala73/worldmonitor/blob/ffec79ac339946fd2d24e85845da5755dcaa534b/convex/companyMonitoring/claimPolicyMigration.ts#L16-L52","documentation":"Error \"COMPANY_MONITORING_ACCOUNT_NOT_FOUND\" thrown in koala73/worldmonitor.","triggerScenarios":"Thrown at convex/companyMonitoring/claimPolicyMigration.ts:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ffec79ac339946fd2d24e85845da5755dcaa534b","analyzedAt":"2026-08-12T11:24:56.012Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}