Skip to content

Claude Enterprise accounts: "missing session data" because spend-limit response has no session windows #925

@Brandawg93

Description

@Brandawg93

Summary

Claude Enterprise accounts fail to display usage in CodexBar with:

Could not parse Claude usage: missing session data

Enterprise plans don't have session-based rate limit windows (five_hour, seven_day, etc.) — they use a single monthly spend limit (e.g., $600/month). The OAuth usage endpoint returns spend data in extra_usage instead of the session window fields, so CodexBar's fallback chain in mapOAuthUsage exhausts and throws.

This is distinct from the previously-fixed five-hour-window omission in #726 / v0.24 — that fix added fallback through seven_day variants, but Enterprise responses have none of those windows.

What the dashboard shows

For reference, the Claude account dashboard renders this Enterprise data correctly:

Your usage limits — Enterprise
$434.43 of $600.00 spent · Spend limit · Resets Jun 1 · 72% used

CodexBar should be able to render the same.

Likely response shape (Enterprise)

{
  "extra_usage": {
    "is_enabled": true,
    "monthly_limit": 600,
    "used_credits": 434.43,
    "utilization": 72,
    "currency": "USD"
  }
  // no five_hour, no seven_day, no seven_day_opus, etc.
}

Root Cause

In ClaudeUsageFetcher.swift:mapOAuthUsage(_:credentials:), the v0.24 fallback chain is:

guard let primary = makeWindow(usage.fiveHour, windowMinutes: 5 * 60)
    ?? makeWindow(usage.sevenDay, windowMinutes: 7 * 24 * 60)
    ?? makeWindow(usage.sevenDayOAuthApps, windowMinutes: 7 * 24 * 60)
    ?? makeWindow(usage.sevenDaySonnet, windowMinutes: 7 * 24 * 60)
    ?? makeWindow(usage.sevenDayOpus, windowMinutes: 7 * 24 * 60)
else {
    throw ClaudeUsageError.parseFailed("missing session data")
}

None of those fields are present for Enterprise responses, so the guard always fails.

Suggested Fix

  1. Detect Enterprise plans (via subscriptionType and/or the presence of extra_usage.monthly_limit without any session windows) and render a spend-limit card instead of a session window — mirroring the dashboard's "$X of $Y spent · N% used · Resets ..." display.
  2. As a minimum, when no session windows are present but extra_usage is valid, return successfully with the spend data populated rather than throwing missing session data.

Reproduction

  1. Use a Claude Enterprise account (long-lived OAuth token via claude setup-token)
  2. Set CodexBar Claude Usage source = OAuth API
  3. Provider shows "last fetch failed: Could not parse Claude usage: missing session data" despite the API returning valid Enterprise spend data

Environment

  • CodexBar 0.25.1 (May 11)
  • Claude Code 2.1.128
  • Account type: Claude Enterprise with monthly spend limit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions