Repository navigation
Description
Bug Description
HOST, PORT and UVICORN_WORKERS are read by cmd_serve in devops_agent/cli.py, but that module never calls load_dotenv(). The only load_dotenv() on the serve path lives in api/server.py, which uvicorn imports from the string "api.server:app" — i.e. after cmd_serve has already read the three values. So setting them in .env has no effect; they must be exported into the environment.
.env.example gives no hint of this, so the three read as ordinary configurable settings.
Steps to Reproduce
- Put
HOST=203.0.113.7,PORT=7777andUVICORN_WORKERS=9in.envand nothing in the shell environment - Run
devops-agent serve - Observe the address, port and worker count the server binds with
Expected Behavior
Values in .env are honoured, as they are for every other setting the project documents there.
Actual Behavior
All three are ignored and the hardcoded defaults win:
running: devops-agent serve
uvicorn.run() reached. The server would bind:
host = '127.0.0.1'
port = 8000
workers = 2
(CLI exited with code 0)
os.environ['HOST'] after the serve path: None
--- control: import api.server, which DOES call load_dotenv() (line 35) ---
os.environ['HOST'] after importing api.server: '203.0.113.7'
The control matters: the same .env file is honoured the moment api.server is imported, so the file is well-formed and loadable and this is purely an import-ordering defect rather than a broken fixture.
Reproduced by driving the real devops_agent.cli.main() with real argv devops-agent serve; only uvicorn.run was stubbed. None of the three variables was set in the ambient shell — confirmed before the run.
Expected vs actual, by line (on main)
devops_agent/cli.py— noimport dotenvand noload_dotenvanywhere in the filedevops_agent/cli.py:18-20— the threeos.getenvreads, insidecmd_serve(:14)devops_agent/cli.py:26—uvicorn.run(...), after the readsapi/server.py:13importsload_dotenv,:35calls it — too late for the three above
Environment
- OS: Debian 13
- Python Version: 3.13.14
- Agent Version/Commit:
ace3dc21ba2ee58ef748b39a31f7ec6049bd6d88(main) - Deployment Method: local
- Platform: n/a — reproduces from the CLI alone
Configuration
HOST=203.0.113.7
PORT=7777
UVICORN_WORKERS=9Additional Context
Found while documenting environment variables for #15. That PR documents the caveat rather than changing behaviour, since a fix alters how the server starts.
Possible Solution
Unverified: calling load_dotenv() near the top of devops_agent/cli.py, before cmd_serve reads the environment, would make the three behave like every other documented setting. Worth checking it does not disturb the ordering api/server.py relies on.
Activity