Spaces:
Running
Running
π Add detailed Supabase connection debugging
Browse files- Enhanced error logging with connection details
- Show URL and key info for troubleshooting
- Help diagnose legacy vs JWT key issues
This will help us see exactly why the connection is failing
and whether it's a key format issue or something else.
- supabase_client.py +13 -3
supabase_client.py
CHANGED
@@ -127,13 +127,23 @@ def create_storage_buckets():
|
|
127 |
|
128 |
# Test connection
|
129 |
def test_supabase_connection() -> bool:
|
130 |
-
"""Test Supabase connection"""
|
131 |
try:
|
|
|
|
|
|
|
132 |
client = get_supabase_client()
|
133 |
-
|
|
|
|
|
|
|
|
|
134 |
result = client.table('trees').select("id").limit(1).execute()
|
135 |
logger.info("Supabase connection successful")
|
136 |
return True
|
|
|
137 |
except Exception as e:
|
138 |
-
logger.error(f"Supabase connection failed: {e}")
|
|
|
|
|
139 |
return False
|
|
|
127 |
|
128 |
# Test connection
|
129 |
def test_supabase_connection() -> bool:
|
130 |
+
"""Test Supabase connection with detailed debugging"""
|
131 |
try:
|
132 |
+
logger.info(f"Testing connection to: {SUPABASE_URL}")
|
133 |
+
logger.info(f"Using anon key (first 20 chars): {SUPABASE_ANON_KEY[:20]}...")
|
134 |
+
|
135 |
client = get_supabase_client()
|
136 |
+
|
137 |
+
# Try a simple REST API call first
|
138 |
+
logger.info("Attempting to connect to Supabase REST API...")
|
139 |
+
|
140 |
+
# Try to query the trees table (will create it if it doesn't exist)
|
141 |
result = client.table('trees').select("id").limit(1).execute()
|
142 |
logger.info("Supabase connection successful")
|
143 |
return True
|
144 |
+
|
145 |
except Exception as e:
|
146 |
+
logger.error(f"Supabase connection failed: {type(e).__name__}: {e}")
|
147 |
+
logger.error(f"URL: {SUPABASE_URL}")
|
148 |
+
logger.error(f"Key type: {type(SUPABASE_ANON_KEY)}, Length: {len(SUPABASE_ANON_KEY) if SUPABASE_ANON_KEY else 0}")
|
149 |
return False
|