Skip to content

fix(claude): use far-future expiry for setup-token credentials#352

Merged
dpup merged 1 commit into
majorcontext:mainfrom
abezzub-dr:fix/claude-zero-expiresat-fallback
May 18, 2026
Merged

fix(claude): use far-future expiry for setup-token credentials#352
dpup merged 1 commit into
majorcontext:mainfrom
abezzub-dr:fix/claude-zero-expiresat-fallback

Conversation

@abezzub-dr
Copy link
Copy Markdown
Contributor

Summary

Split out of #308 per @dpup's review.

Setup-token grants don't set ExpiresAt on the credential, leaving it as the zero time.Time. WriteCredentialsFile called UnixMilli() on this, producing -62135596800000 (year 0001) in .credentials.json. Claude Code read that as an expired credential, showing "not logged in" and "API Usage Billing" in the status line instead of recognizing the session.

Substitute a 1-year-ahead timestamp when ExpiresAt is zero. Setup-tokens are long-lived and the placeholder credential just needs to look valid locally — the real token is injected by the proxy at the network layer.

Test plan

  • make test-unit for internal/providers/claude
  • make lint
  • moat claude with a setup-token grant no longer reports "not logged in"

Setup-token grants don't set ExpiresAt on the credential, leaving it as
the zero time.Time. WriteCredentialsFile called UnixMilli() on this,
producing -62135596800000 (year 0001) in .credentials.json. Claude Code
read that as an expired credential, showing "not logged in" and
"API Usage Billing" in the status line instead of recognizing the
session.

Use a 1-year-ahead timestamp when ExpiresAt is zero. Setup-tokens are
long-lived and the placeholder credential just needs to look valid
locally — the real token is injected by the proxy at the network layer.
@dpup dpup merged commit 223bce5 into majorcontext:main May 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants