File size: 1,902 Bytes
80a4a65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Diagnostic: print the resolved .env location and all critical keys.

Run with:

    python scripts/check_env.py

Useful when "missing supabase key" appears — confirms whether the
backend actually loaded CyberArena/.env or picked up a stray copy.
"""

from __future__ import annotations

import os
import sys
from pathlib import Path


HERE = Path(__file__).resolve()
BACKEND_DIR = HERE.parent.parent


def main() -> int:
    os.chdir(BACKEND_DIR)
    sys.path.insert(0, str(BACKEND_DIR))

    print("=" * 70)
    print(f"Backend dir: {BACKEND_DIR}")
    print(f"Working dir: {Path.cwd()}")
    print("=" * 70)

    # 1) Show every .env file we can see in the project
    print("\n[1] .env files found anywhere in the project:")
    for path in sorted(BACKEND_DIR.rglob(".env*")):
        if "__pycache__" in path.parts:
            continue
        size = path.stat().st_size
        print(f"    - {path}  ({size} bytes)")

    # 2) Trigger the loader
    from app._env import load_app_env
    loaded = load_app_env(verbose=True)

    # 3) Show what made it into os.environ
    print("\n[2] os.environ values after load:")
    for key in (
        "SUPABASE_URL",
        "SUPABASE_ANON_KEY",
        "CLOUDFLARE_API_TOKEN",
        "CLOUDFLARE_ACCOUNT_ID",
        "CLOUDFLARE_MODEL",
        "GROQ_API_KEY",
        "GROQ_MODEL",
        "NVIDIA_API_KEY",
        "NVIDIA_MODEL",
        "MISTRAL_API_KEY",
        "MISTRAL_MODEL",
    ):
        val = os.environ.get(key, "")
        if not val:
            print(f"    {key:25s}  <MISSING>")
        elif "KEY" in key or "TOKEN" in key:
            print(f"    {key:25s}  {val[:4]}{val[-4:]}  (len={len(val)})")
        else:
            print(f"    {key:25s}  {val}")

    print("\n[3] Loaded file:", loaded or "<NONE — using process env only>")
    print("=" * 70)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())