mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 11:59:26 +00:00
fix: remove extra Exception from debug.py
This commit is contained in:
parent
05450ae7dc
commit
50ad84d27d
1 changed files with 16 additions and 22 deletions
|
|
@ -11,7 +11,7 @@ router = APIRouter()
|
|||
async def debug_deployment():
|
||||
"""Debug endpoint for deployment verification and isolation testing"""
|
||||
learnhouse_config = get_learnhouse_config()
|
||||
|
||||
|
||||
# Parse database host safely
|
||||
db_host = "unknown"
|
||||
db_user = "unknown"
|
||||
|
|
@ -27,7 +27,7 @@ async def debug_deployment():
|
|||
user_parts = auth_parts[1].split(':')
|
||||
if len(user_parts) > 0:
|
||||
db_user = user_parts[0]
|
||||
|
||||
|
||||
# Extract host and database name
|
||||
host_parts = auth_host_parts[1].split('/')
|
||||
if len(host_parts) > 0:
|
||||
|
|
@ -36,7 +36,7 @@ async def debug_deployment():
|
|||
db_name = host_parts[1]
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
# Parse redis host safely
|
||||
redis_host = "unknown"
|
||||
redis_db = "unknown"
|
||||
|
|
@ -51,7 +51,7 @@ async def debug_deployment():
|
|||
redis_db = host_parts[1].split('/')[1]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# Get hostname information
|
||||
import socket
|
||||
hostname = "unknown"
|
||||
|
|
@ -59,7 +59,7 @@ async def debug_deployment():
|
|||
hostname = socket.gethostname()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# Get process and container info
|
||||
container_id = "unknown"
|
||||
try:
|
||||
|
|
@ -71,7 +71,7 @@ async def debug_deployment():
|
|||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
return {
|
||||
"deployment_name": os.environ.get('DEPLOYMENT_NAME', 'NOT_SET'),
|
||||
"hostname": hostname,
|
||||
|
|
@ -104,12 +104,12 @@ async def debug_urls(request: Request):
|
|||
"edu.adradviser.ro", # LIVE domain
|
||||
"adr-lms.whitex.cloud" # DEV domain
|
||||
]
|
||||
|
||||
|
||||
# Add any additional domains from environment variables
|
||||
current_domain = os.environ.get('NEXT_PUBLIC_LEARNHOUSE_DOMAIN', '')
|
||||
if current_domain and current_domain not in known_domains:
|
||||
known_domains.append(current_domain)
|
||||
|
||||
|
||||
# Build patterns for all domains to detect cross-contamination
|
||||
patterns = []
|
||||
for domain in known_domains:
|
||||
|
|
@ -122,7 +122,7 @@ async def debug_urls(request: Request):
|
|||
f"fetch\\(\"https://{domain}",
|
||||
f"fetch\\(\"http://{domain}",
|
||||
])
|
||||
|
||||
|
||||
# Add general patterns for NextAuth configuration
|
||||
patterns.extend([
|
||||
"\"/api/auth/session\"",
|
||||
|
|
@ -134,10 +134,10 @@ async def debug_urls(request: Request):
|
|||
"NEXTAUTH_URL=\"[^\"]*\"",
|
||||
"NEXTAUTH_URL='[^']*'"
|
||||
])
|
||||
|
||||
|
||||
all_urls = []
|
||||
domain_matches = {domain: [] for domain in known_domains}
|
||||
|
||||
|
||||
# Search for URLs in JS files
|
||||
for pattern in patterns:
|
||||
result = subprocess.run(
|
||||
|
|
@ -147,13 +147,13 @@ async def debug_urls(request: Request):
|
|||
if result.stdout.strip():
|
||||
found_urls = list(set(result.stdout.strip().split('\n')))
|
||||
all_urls.extend(found_urls)
|
||||
|
||||
|
||||
# Categorize URLs by domain
|
||||
for url in found_urls:
|
||||
for domain in known_domains:
|
||||
if domain in url:
|
||||
domain_matches[domain].append(url)
|
||||
|
||||
|
||||
# Look for NextAuth configuration
|
||||
auth_configs = []
|
||||
try:
|
||||
|
|
@ -165,7 +165,7 @@ async def debug_urls(request: Request):
|
|||
auth_configs = list(set(auth_result.stdout.strip().split('\n')))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# Gather environment variable information
|
||||
env_vars = {
|
||||
"NEXT_PUBLIC_LEARNHOUSE_DOMAIN": os.environ.get('NEXT_PUBLIC_LEARNHOUSE_DOMAIN', 'NOT_SET'),
|
||||
|
|
@ -175,14 +175,14 @@ async def debug_urls(request: Request):
|
|||
"NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN": os.environ.get('NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN', 'NOT_SET'),
|
||||
"LEARNHOUSE_COOKIE_DOMAIN": os.environ.get('LEARNHOUSE_COOKIE_DOMAIN', 'NOT_SET')
|
||||
}
|
||||
|
||||
|
||||
# Get the top domain from an environment variable or extract from current domain
|
||||
top_domain = os.environ.get('NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN', '')
|
||||
if not top_domain and current_domain:
|
||||
parts = current_domain.split('.')
|
||||
if len(parts) >= 2:
|
||||
top_domain = '.'.join(parts[-2:])
|
||||
|
||||
|
||||
return {
|
||||
"detected_hardcoded_urls": all_urls,
|
||||
"domain_specific_matches": domain_matches,
|
||||
|
|
@ -201,9 +201,3 @@ async def debug_urls(request: Request):
|
|||
"message": "Could not scan for hardcoded URLs",
|
||||
"deployment_name": os.environ.get('DEPLOYMENT_NAME', 'NOT_SET')
|
||||
}
|
||||
except Exception as e:
|
||||
return {
|
||||
"error": str(e),
|
||||
"message": "Could not scan for hardcoded URLs",
|
||||
"deployment_name": os.environ.get('DEPLOYMENT_NAME', 'NOT_SET')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue