Spaces:
Sleeping

valent-p commited on
Commit
c99086b
·
1 Parent(s): 92bdcb0

feat: add Supabase client initialization with environment variable validation.

Browse files
Files changed (1) hide show
  1. src/database.py +10 -3
src/database.py CHANGED
@@ -2,10 +2,17 @@ import os
2
  from supabase import create_client, Client
3
 
4
  # Ensure these environment variables are set
5
- url: str = os.environ.get("SUPABASE_URL", "")
6
- key: str = os.environ.get("SUPABASE_KEY", "")
7
 
8
  if not url or not key:
9
- raise RuntimeError("Missing SUPABASE_URL or SUPABASE_KEY environment variables. Please set them.")
 
 
 
 
 
 
 
10
 
11
  supabase: Client = create_client(url, key)
 
2
  from supabase import create_client, Client
3
 
4
  # Ensure these environment variables are set
5
+ url: str = os.environ.get("SUPABASE_URL", "").strip().strip("'").strip('"')
6
+ key: str = os.environ.get("SUPABASE_KEY", "").strip().strip("'").strip('"')
7
 
8
  if not url or not key:
9
+ print("[-] CRITICAL: SUPABASE_URL or SUPABASE_KEY not set in environment.")
10
+ raise RuntimeError("Missing SUPABASE_URL or SUPABASE_KEY environment variables.")
11
+
12
+ if not url.startswith("https://"):
13
+ print(f"[-] CRITICAL: Invalid SUPABASE_URL format: {url}")
14
+ raise RuntimeError(f"SUPABASE_URL must start with 'https://'. Got: {url}")
15
+
16
+ print(f"[*] Initializing Supabase Client with URL: {url[:15]}...{url[-5:]} (Masked)")
17
 
18
  supabase: Client = create_client(url, key)