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 lines525354555657585960616263646551 unmodified linestry:return json.loads(raw)except json.JSONDecodeError as e:raise RuntimeError("Invalid GOOGLE_SERVICE_ACCOUNT_JSON") from epath = 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"))return None51 unmodified lines5253545556575859606162636465666768697071727351 unmodified linestry:return json.loads(raw)except json.JSONDecodeError as e:# Log warning but don't crash; Drive features will be unavailableimport sysprint(f"⚠️ GOOGLE_SERVICE_ACCOUNT_JSON is invalid JSON. Drive features disabled.", file=sys.stderr)return Nonepath = os.environ.get("GOOGLE_SERVICE_ACCOUNT_FILE", "").strip()if path:p = Path(path)if not p.exists():print(f"⚠️ GOOGLE_SERVICE_ACCOUNT_FILE not found: {path}. Drive features disabled.", file=sys.stderr)return Nonetry: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 Nonereturn None
drive_utils.py+11-3