unionlabs/union · error · Error

Failed to check contribution status

Error message

Failed to check contribution status

What it means

Catch-all at the end of getContributionState: any exception thrown by the four parallel Supabase queries or the status-derivation logic is console.logged and re-thrown as this generic Error, discarding the original cause. The real reason (RLS denial, network failure, malformed data) is only visible in the preceding console.log.

Source

Thrown at ceremony/src/lib/supabase/index.ts:128

    let status: ContributionState

    if (isContributor && !hasSubmitted && !hasVerified) {
      status = "contribute"
    } else if (isContributor && hasSubmitted && !hasVerified) {
      status = "verifying"
    } else if (hasVerified) {
      status = "contributed"
    } else if (!hasSubmitted && isExpired) {
      status = "missed"
    } else {
      status = "notContributed"
    }

    return status
  } catch (error) {
    console.log("Error checking contribution status:", error)
    throw new Error("Failed to check contribution status")
  }
}

export const getCurrentUserState = async (userId: string | undefined): Promise<AllowanceState> => {
  if (!userId) {
    console.log("Need to be logged in to get allowance state")
    return undefined
  }

  const { data, error } = await queryCurrentUserState()
  if (error || !data) {
    return undefined
  }

  if (data.in_queue) {
    return "inQueue"
  }
  if (data.has_redeemed) {

View on GitHub (pinned to 031785bb6d)

Solutions

  1. Check the console output for 'Error checking contribution status:' — the underlying error is printed there and names the real cause
  2. If the cause is a JWT/auth error, refresh the session (supabase.auth.refreshSession) or re-login
  3. Verify RLS policies grant the authenticated role SELECT on the queried tables for the user's auth.uid()
  4. Attach the original error via { cause } (or rethrow it) so callers and logs keep the stack

Example fix

// before
} catch (error) {
  console.log("Error checking contribution status:", error)
  throw new Error("Failed to check contribution status")
}

// after
} catch (error) {
  console.error("Error checking contribution status:", error)
  throw new Error("Failed to check contribution status", { cause: error })
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const state = await getContributionState()
} catch (e) {
  if (e instanceof Error && e.message === "Failed to check contribution status") {
    // the real cause was console.logged; check devtools, then:
    await supabase.auth.refreshSession() // if JWT expiry is the cause
    return retryOnce()
  }
  throw e
}

Prevention

When it happens

Trigger: Row Level Security denying SELECT on contributor/contribution tables to the current auth.uid(); network or Supabase outage during the Promise.all; unexpected null/shape in query results breaking the status computation.

Common situations: RLS policies not covering a new table or role; expired/invalid JWT mid-session; schema changes after a ceremony migration.

Related errors


AI-assisted analysis of unionlabs/union@031785bb6d (2026-08-16). Data as JSON: /api/errors/217df52e60e120ef. Report an issue: GitHub.