Summary
The proxies read the API key from the process environment only
(os.environ.get("LLAMA_API_KEY")), but nothing loads .env. So whether
the server comes up authenticated depends entirely on the shell that launched it
having $env:LLAMA_API_KEY exported.
Observed:
.env contains LLAMA_API_KEY, but no code reads it (stdlib + aiohttp only, no
python-dotenv).
- No PowerShell profile sets it (none exist), and it is not a persistent
env var (User/Machine scope both empty).
watchdog.ps1 / watchdog-embed.ps1 don't load .env either.
Result: launching from a fresh terminal (or a Task Scheduler context) that didn't
export the key brings the proxy up with auth disabled (the auth_middleware
skips auth when config.api_key is falsy), which is a silent security footgun.
Proposed fix
Load .env at startup in both proxy.py and embed_proxy.py using stdlib only
(no new dependency): parse KEY=VALUE lines from .env next to the script and
os.environ.setdefault(...) each one.
- Use
setdefault so an already-exported env var always wins (no surprise
overrides; explicit env still takes precedence).
- Tolerate a missing
.env (no-op), comments (#), blank lines, and quoted
values.
- Keep it shared (e.g. a small helper) so both proxies behave identically.
Acceptance criteria
- Launching either proxy from a shell with no
LLAMA_API_KEY exported still
comes up authenticated using the value in .env.
- An explicitly exported
LLAMA_API_KEY overrides the .env value.
- Missing
.env does not crash startup.
- No new third-party dependencies;
.env stays gitignored.
Summary
The proxies read the API key from the process environment only
(
os.environ.get("LLAMA_API_KEY")), but nothing loads.env. So whetherthe server comes up authenticated depends entirely on the shell that launched it
having
$env:LLAMA_API_KEYexported.Observed:
.envcontainsLLAMA_API_KEY, but no code reads it (stdlib + aiohttp only, nopython-dotenv).env var (User/Machine scope both empty).
watchdog.ps1/watchdog-embed.ps1don't load.enveither.Result: launching from a fresh terminal (or a Task Scheduler context) that didn't
export the key brings the proxy up with auth disabled (the
auth_middlewareskips auth when
config.api_keyis falsy), which is a silent security footgun.Proposed fix
Load
.envat startup in bothproxy.pyandembed_proxy.pyusing stdlib only(no new dependency): parse
KEY=VALUElines from.envnext to the script andos.environ.setdefault(...)each one.setdefaultso an already-exported env var always wins (no surpriseoverrides; explicit env still takes precedence).
.env(no-op), comments (#), blank lines, and quotedvalues.
Acceptance criteria
LLAMA_API_KEYexported stillcomes up authenticated using the value in
.env.LLAMA_API_KEYoverrides the.envvalue..envdoes not crash startup..envstays gitignored.