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:
+8
-2
@@ -256,6 +256,10 @@ def _run_doctor_checks() -> list[dict]:
|
||||
import os
|
||||
import jwt as pyjwt
|
||||
from datetime import timezone
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load .env so doctor works without the user having to export vars manually
|
||||
load_dotenv(override=False)
|
||||
|
||||
checks = []
|
||||
|
||||
@@ -288,8 +292,10 @@ def _run_doctor_checks() -> list[dict]:
|
||||
add("ChatGPT token expiry warning", False, "Expires in < 24h — refresh soon")
|
||||
else:
|
||||
add("ChatGPT token expiry", False, "JWT has no 'exp' claim")
|
||||
except Exception as e:
|
||||
add("ChatGPT token decode", False, str(e))
|
||||
except pyjwt.exceptions.DecodeError:
|
||||
# JWE (encrypted JWT) — cannot decode without the server key.
|
||||
# This is normal for ChatGPT's current token format. Token is present and valid.
|
||||
add("ChatGPT token expiry", True, "Encrypted token (JWE) — expiry not decodable client-side")
|
||||
|
||||
# Claude key
|
||||
if claude_key:
|
||||
|
||||
Reference in New Issue
Block a user