Skip to content

MiniMax OAuth login fails with year 58381 is out of range #21779

@tairea

Description

@tairea

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/authAuthentication, OAuth, credential poolscomp/cliCLI entry point, hermes_cli/, setup wizardprovider/minimaxMiniMax (Anthropic transport)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions