hermes - 💡(How to fix) Fix MiniMax OAuth login fails with `year 58381 is out of range`

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

MiniMax's /oauth/token returns expired_in as a unix-ms timestamp (matching OpenClaw's Date.now() < expireTimeMs convention), not a TTL in seconds. _minimax_poll_token in hermes_cli/auth.py already documents and handles this defensively for the polling deadline, but the two call sites that persist the resulting auth state do not:

  • _minimax_oauth_login (~line 4876):
    expires_in_s = int(token_data["expired_in"])
    expires_at = now.timestamp() + expires_in_s
    ...
    datetime.fromtimestamp(expires_at, tz=timezone.utc).isoformat()
  • _refresh_minimax_oauth_state (~line 4952): same pattern.

With expired_in ≈ 1.78e12 (ms) added to now.timestamp() (~1.78e9 s), fromtimestamp is called with ~1.78e12 → year ~58381 → OverflowError: year 58381 is out of range.

Fix Action

Fix / Workaround

I've patched it locally and verified login completes — happy to send a PR.

Code Example

Login failed: year 58381 is out of range

---

expires_in_s = int(token_data["expired_in"])
  expires_at = now.timestamp() + expires_in_s
  ...
  datetime.fromtimestamp(expires_at, tz=timezone.utc).isoformat()

---

def _minimax_parse_expired_in(value):
    """Returns (expires_at_epoch_seconds, ttl_seconds).

    OpenClaw treats `expired_in` as a unix-ms timestamp; fall back to
    TTL-in-seconds if the value is too small to be an epoch.
    """
    raw = int(value)
    now_s = time.time()
    if raw > int(now_s * 1000) // 2:
        expires_at_s = raw / 1000.0
        ttl_s = max(1, int(expires_at_s - now_s))
    else:
        ttl_s = max(1, raw)
        expires_at_s = now_s + ttl_s
    return expires_at_s, ttl_s

---

# poll
deadline, _ = _minimax_parse_expired_in(expired_in)

# login + refresh
expires_at_s, expires_in_s = _minimax_parse_expired_in(token_data["expired_in"])
...
"expires_at": datetime.fromtimestamp(expires_at_s, tz=timezone.utc).isoformat(),
"expires_in": expires_in_s,
RAW_BUFFERClick to expand / collapse

hermes MiniMax OAuth login fails immediately after the user approves in the browser:

Login failed: year 58381 is out of range

Root cause

MiniMax's /oauth/token returns expired_in as a unix-ms timestamp (matching OpenClaw's Date.now() < expireTimeMs convention), not a TTL in seconds. _minimax_poll_token in hermes_cli/auth.py already documents and handles this defensively for the polling deadline, but the two call sites that persist the resulting auth state do not:

  • _minimax_oauth_login (~line 4876):
    expires_in_s = int(token_data["expired_in"])
    expires_at = now.timestamp() + expires_in_s
    ...
    datetime.fromtimestamp(expires_at, tz=timezone.utc).isoformat()
  • _refresh_minimax_oauth_state (~line 4952): same pattern.

With expired_in ≈ 1.78e12 (ms) added to now.timestamp() (~1.78e9 s), fromtimestamp is called with ~1.78e12 → year ~58381 → OverflowError: year 58381 is out of range.

Suggested fix

Factor the existing defensive parsing in _minimax_poll_token into a helper and reuse it in both save paths. The module already imports time at the top, so no extra import shim is needed:

def _minimax_parse_expired_in(value):
    """Returns (expires_at_epoch_seconds, ttl_seconds).

    OpenClaw treats `expired_in` as a unix-ms timestamp; fall back to
    TTL-in-seconds if the value is too small to be an epoch.
    """
    raw = int(value)
    now_s = time.time()
    if raw > int(now_s * 1000) // 2:
        expires_at_s = raw / 1000.0
        ttl_s = max(1, int(expires_at_s - now_s))
    else:
        ttl_s = max(1, raw)
        expires_at_s = now_s + ttl_s
    return expires_at_s, ttl_s

Then in _minimax_poll_token, _minimax_oauth_login, and _refresh_minimax_oauth_state:

# poll
deadline, _ = _minimax_parse_expired_in(expired_in)

# login + refresh
expires_at_s, expires_in_s = _minimax_parse_expired_in(token_data["expired_in"])
...
"expires_at": datetime.fromtimestamp(expires_at_s, tz=timezone.utc).isoformat(),
"expires_in": expires_in_s,

Repro

  1. hermes → choose MiniMax (OAuth · minimax.io)
  2. Approve in the browser
  3. CLI prints Login failed: year 58381 is out of range

Environment

  • Hermes commit: faa13e49f (docs(web): fix SearXNG env configuration)
  • Python on Ubuntu 26.04

I've patched it locally and verified login completes — happy to send a PR.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING