Lara Monteagudo Tubau commited on
Commit ·
673acc0
1
Parent(s): da4b58e
Make Drive credentials loading graceful; handle missing/invalid JSON without crashing
Browse files51 unmodified lines5253545555565758596061626361626465666768697071727351 unmodified lines try: return json.loads(raw) except json.JSONDecodeError as e: raise RuntimeError("Invalid GOOGLE_SERVICE_ACCOUNT_JSON") from e # Log warning but don't crash; Drive features will be unavailable import sys print(f"⚠️ GOOGLE_SERVICE_ACCOUNT_JSON is invalid JSON. Drive features disabled.", file=sys.stderr) return None
path = os.environ.get("GOOGLE_SERVICE_ACCOUNT_FILE", "").strip() if path: p = Path(path) if not p.exists(): raise RuntimeError(f"GOOGLE_SERVICE_ACCOUNT_FILE not found: {path}") return json.loads(p.read_text(encoding="utf-8")) print(f"⚠️ GOOGLE_SERVICE_ACCOUNT_FILE not found: {path}. Drive features disabled.", file=sys.stderr) return None try: return json.loads(p.read_text(encoding="utf-8")) except json.JSONDecodeError as e: print(f"⚠️ GOOGLE_SERVICE_ACCOUNT_FILE is invalid JSON. Drive features disabled.", file=sys.stderr) return None
return None
drive_utils.py+11-3