{"record":{"id":"c99db2c6ebe38809","repo":"unionlabs/union","slug":"user-id-is-required","errorCode":null,"errorMessage":"User ID is required","messagePattern":"User ID is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ceremony/src/lib/supabase/index.ts","lineNumber":92,"sourceCode":"      inQueue: false,\n      message: \"User not found in the queue\",\n    }\n  }\n\n  return {\n    inQueue: true,\n    count: count,\n    ...data,\n  }\n}\n\nexport const getContributionState = async (): Promise<ContributionState> => {\n  if (!user.session) {\n    throw new Error(\"User is not logged in\")\n  }\n  const userId = user.session.user.id\n  if (!userId) {\n    throw new Error(\"User ID is required\")\n  }\n\n  try {\n    const [contributor, submittedContribution, verifiedContribution, contributionWindow] =\n      await Promise.all([\n        queryContributor(userId),\n        querySubmittedContribution(userId),\n        queryContribution(userId),\n        queryContributionWindow(userId),\n      ])\n\n    const isContributor = !!contributor?.data\n    const hasSubmitted = !!submittedContribution?.data\n    const hasVerified = !!verifiedContribution?.data\n    const isExpired = contributionWindow?.data?.expire\n      ? Date.now() > new Date(contributionWindow.data.expire).getTime()\n      : false\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/unionlabs/union/blob/031785bb6dc6b957c624e62bc64c184409c97d7b/ceremony/src/lib/supabase/index.ts#L74-L110","documentation":"Companion guard to the session check in getContributionState: a session exists but session.user.id is falsy, so there is no userId to pass to queryContributor/querySubmittedContribution/etc. It indicates a degenerate session object rather than a logged-out user.","triggerScenarios":"Partially restored or malformed session (token without user payload); session persisted by an older Supabase client version after a project update.","commonSituations":"Post-migration stale auth state in localStorage; interrupted sign-in callbacks.","solutions":["Sign out and sign in again to rebuild a well-formed session","Validate session.user.id (not just session) before calling getContributionState","Clear stale Supabase auth keys from localStorage if the problem persists"],"exampleFix":"// before\nif (!user.session) throw new Error(\"User is not logged in\")\nconst userId = user.session.user.id\n\n// after\nconst userId = user.session?.user?.id\nif (!userId) {\n  await supabase.auth.signOut()\n  throw new Error(\"User is not logged in\")\n}","handlingStrategy":"validation","validationCode":"const userId = user.session?.user?.id\nif (!userId) {\n  await supabase.auth.signOut()\n  await goto(\"/login\")\n  return\n}\nawait getContributionState()","typeGuard":"const hasUserId = (s: Session | null): s is Session & { user: { id: string } } =>\n  typeof s?.user?.id === \"string\" && s.user.id.length > 0","tryCatchPattern":"try {\n  await getContributionState()\n} catch (e) {\n  if (e instanceof Error && e.message === \"User ID is required\") {\n    await supabase.auth.signOut()\n    await goto(\"/login\")\n    return\n  }\n  throw e\n}","preventionTips":["Check session.user.id completeness, not just session existence","Rebuild sessions that lack a user payload via signOut + signIn","Log the session shape when this fires to catch auth-restore bugs early"],"tags":["auth","supabase","session"],"backgroundTag":null,"analyzedSha":"031785bb6dc6b957c624e62bc64c184409c97d7b","analyzedAt":"2026-08-16T06:24:09.996Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}