{"record":{"id":"8fc3f6a768fd0151","repo":"koala73/worldmonitor","slug":"auth-required","errorCode":"AUTH_REQUIRED","errorMessage":"AUTH_REQUIRED","messagePattern":"AUTH_REQUIRED","errorType":"error_code","errorClass":"ConvexError","httpStatus":null,"severity":"error","filePath":"convex/lib/auth.ts","lineNumber":65,"sourceCode":"  const plan = identity.plan === 'free' || identity.plan === 'pro' ? identity.plan : undefined;\n  return { ...identity, plan };\n}\n\n/**\n * Returns the current user's ID or throws if unauthenticated.\n * Use for mutations/actions that always require auth.\n */\nexport async function requireUserId(\n  ctx: QueryCtx | MutationCtx | ActionCtx,\n): Promise<string> {\n  const userId = await resolveUserId(ctx);\n  if (!userId) {\n    // ConvexError so clients can narrow AUTH_REQUIRED via the ConvexError\n    // contract (error.data). It is NOT exempt from Convex→Sentry reporting —\n    // expected denials still appear as Uncaught ConvexError (e.g. WORLDMONITOR-XM).\n    // High-frequency expected denials need a return value, not a throw, to stay\n    // out of exception ingest; do not suppress these codes by message at Sentry.\n    throw new ConvexError(\"AUTH_REQUIRED\");\n  }\n  return userId;\n}\n","sourceCodeStart":47,"sourceCodeEnd":69,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/convex/lib/auth.ts#L47-L69","documentation":"Auth gate from requireUserId in convex/lib/auth.ts: resolveUserId found no authenticated identity. Thrown deliberately as a ConvexError so Convex's server-side Sentry treats it as an expected business error (WebSocket/auth races on query fire) rather than reporting every unauthenticated call.","triggerScenarios":"Thrown at convex/lib/auth.ts:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the client establishes an auth session before invoking the mutation or query","For fire-on-load queries, expect this error during sign-out races and handle it silently client-side"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-09-22T01:50:49.965Z","contentChangedAt":"2026-09-22T01:50:49.965Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}