IntegraChat / check_env.py
nothingworry's picture
refactor(analytics): Remove SQLite fallback, require Supabase exclusively
d74c0dc
raw
history blame
3.61 kB
#!/usr/bin/env python3
"""
Simple script to check Supabase environment variables
"""
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
# Load .env file
load_dotenv()
print("=" * 70)
print("Supabase Environment Variables Check")
print("=" * 70)
print()
# Check SUPABASE_URL
supabase_url = os.getenv("SUPABASE_URL")
if supabase_url:
print(f"[OK] SUPABASE_URL is set")
print(f" Value: {supabase_url}")
if not supabase_url.startswith("https://"):
print(f" [WARNING] URL should start with https://")
if ".supabase.co" not in supabase_url:
print(f" [WARNING] URL should contain .supabase.co")
else:
print("[ERROR] SUPABASE_URL is NOT set")
print(" Required for Supabase integration")
print()
# Check SUPABASE_SERVICE_KEY
supabase_key = os.getenv("SUPABASE_SERVICE_KEY")
if supabase_key:
key_length = len(supabase_key)
print(f"[OK] SUPABASE_SERVICE_KEY is set")
print(f" Length: {key_length} characters")
if key_length < 100:
print(f" [ERROR] Key is too short ({key_length} chars)")
print(f" Expected: 200+ characters")
print(f" This looks like an 'anon' key, not 'service_role' key!")
print(f" Get the correct key from:")
print(f" Supabase Dashboard -> Settings -> API -> service_role key")
elif key_length < 200:
print(f" [WARNING] Key might be incomplete ({key_length} chars)")
print(f" Expected: 200+ characters")
else:
print(f" [OK] Key length looks correct ({key_length} chars)")
# Check if it starts with eyJ (JWT token format)
if supabase_key.startswith("eyJ"):
print(f" [OK] Key format looks correct (JWT token)")
else:
print(f" [WARNING] Key doesn't start with 'eyJ' (unusual for JWT)")
# Show first and last few characters (masked)
if key_length > 20:
masked = supabase_key[:10] + "..." + supabase_key[-10:]
print(f" Preview: {masked}")
else:
print("[ERROR] SUPABASE_SERVICE_KEY is NOT set")
print(" Required for Supabase integration")
print(" Get it from: Supabase Dashboard -> Settings -> API -> service_role key")
print()
# Check POSTGRESQL_URL (optional)
postgres_url = os.getenv("POSTGRESQL_URL")
if postgres_url:
print(f"[INFO] POSTGRESQL_URL is set (optional, for migrations)")
if len(postgres_url) > 50:
masked = postgres_url[:30] + "..." + postgres_url[-20:]
print(f" Value: {masked}")
else:
print(f" Value: {postgres_url}")
else:
print("[INFO] POSTGRESQL_URL is not set (optional, only needed for migrations)")
print()
print("=" * 70)
print("Summary")
print("=" * 70)
has_url = bool(supabase_url)
has_key = bool(supabase_key)
key_valid = has_key and len(supabase_key) >= 200
if has_url and has_key and key_valid:
print("[SUCCESS] Supabase environment variables are correctly configured!")
print(" Your data should upload to Supabase automatically.")
elif has_url and has_key:
print("[WARNING] Supabase URL and key are set, but key appears invalid.")
print(" Check that you're using the 'service_role' key (not 'anon' key).")
elif has_url or has_key:
print("[ERROR] Supabase configuration is incomplete.")
print(" Both SUPABASE_URL and SUPABASE_SERVICE_KEY must be set.")
else:
print("[ERROR] Supabase is not configured.")
print(" Set SUPABASE_URL and SUPABASE_SERVICE_KEY in your .env file.")
print()
print("=" * 70)