fix: load .env in doctor command; handle JWE tokens gracefully
Doctor was reading env vars before loading .env, so tokens set in .env were invisible. ChatGPT now uses JWE (encrypted JWT) tokens which PyJWT cannot decode without the server key — treat decode failure as "token set, expiry unknown" rather than a FAIL. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -125,8 +125,12 @@ def _validate_chatgpt_token(token: str) -> datetime | None:
|
||||
|
||||
try:
|
||||
payload = jwt.decode(token, options={"verify_signature": False})
|
||||
except jwt.DecodeError as e:
|
||||
logger.warning("CHATGPT_SESSION_TOKEN could not be decoded as JWT: %s", e)
|
||||
except jwt.DecodeError:
|
||||
# JWE (encrypted JWT, alg=dir) — cannot be decoded without the server key.
|
||||
# This is normal for ChatGPT's current token format. Token is valid; expiry unknown.
|
||||
logger.debug(
|
||||
"CHATGPT_SESSION_TOKEN is an encrypted JWE token — expiry cannot be decoded client-side."
|
||||
)
|
||||
return None
|
||||
|
||||
exp = payload.get("exp")
|
||||
|
||||
Reference in New Issue
Block a user