Repository navigation
docs: document the 16 env vars code reads but .env.example never mentioned - #42
Merged
OkiriGabriel merged 1 commit intoAug 4, 2026
Conversation
Sixteen variables were read via os.getenv/os.environ with no entry in .env.example, so their defaults silently won in production. Each is now listed with its default (taken from the code), what it controls, and a secret marker where it is a credential: HOST, UVICORN_WORKERS devops_agent/cli.py FASTMCP_HOST, FASTMCP_PORT devops_mcp/server.py STORAGE_CONTAINER storage/factory.py MINIO_ENDPOINT/_ACCESS_KEY/_SECRET_KEY storage/factory.py AZURE_STORAGE_ACCOUNT_URL storage/factory.py AZURE_STORAGE_ACCOUNT storage/azure_storage.py ARGOCD_INSECURE_SKIP_VERIFY collectors/argocd.py SSH_CONNECT_TIMEOUT tools/ssh_utils.py JIRA_PRIORITY_CRITICAL/_HIGH/_MEDIUM/_LOW tools/jira_tools.py FASTMCP_HOST/FASTMCP_PORT ship commented out: the server seeds them with os.environ.setdefault, so a value in .env would silently override the CLI's --host/--port. tests/test_env_example_coverage.py keeps the file honest. It walks the tree with ast, collects every string-literal name passed to os.getenv, os.environ.get/setdefault/pop or os.environ[...], and fails naming any that has no `NAME=` line in .env.example. Parsing the AST rather than grepping means a commented-out or stringified lookup cannot trigger a false failure. TESTING is on an allow-list with the reason it stays out (a CI-only harness flag), and a second test fails if an allow-list entry ever becomes documented, so the list cannot rot. Also corrects JENKINS_USER/JENKINS_TOKEN to the names the code actually reads (JENKINS_USERNAME/JENKINS_API_TOKEN) in docs/GETTING_STARTED.md. Refs open-devops-agent#15 Co-Authored-By: Claude Opus 5 <[email protected]>
Collaborator
|
Reviewed — CI is green across all checks. Env var documentation and drift-prevention test are solid. Merging to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Documents the 16 environment variables that code reads but
.env.examplenever mentioned, and adds a test that fails when a new one appears — so the file cannot drift again.Fixes #15
Type of Change
Platform/Component
I derived the variable list rather than taking the issue's, and the issue is wrong on two counts and short on a third:
SLACK_BOT_TOKENis already documented at.env.example:112-115with a four-line comment — added since the issue was filed. No change made.TESTINGis not read by any Python code.grep -rn "TESTING" --include=*.py .finds only an allow-list entry intests/test_ci_env_alignment.py; it is only set, byci.yml. Documenting it in.env.examplewould advertise a test-harness flag as a production setting, so it is on the new test's allow-list with that reason recorded instead.ARGOCD_INSECURE_SKIP_VERIFY,AZURE_STORAGE_ACCOUNT(distinct from the_URLthe issue lists),SSH_CONNECT_TIMEOUT, and all fourJIRA_PRIORITY_*.Everything else the issue listed is correct and was followed. Defaults are read from the code, not guessed, and the two
MINIO_*credentials are marked as secrets.Also corrected
docs/GETTING_STARTED.md, which documentedJENKINS_USERandJENKINS_TOKEN— the code readsJENKINS_USERNAMEandJENKINS_API_TOKEN(collectors/jenkins.py:17-18,tools/cicd_tools.py:21-22). Anyone following that guide got a silently unauthenticated Jenkins collector.Testing
tests/test_env_example_coverage.pywalks the AST of every*.pyforos.getenv/os.environ.get|setdefault|pop/os.environ[...]and compares against what.env.exampledeclares. AST rather than grep, so the three obvious false positives are structurally impossible — and I proved each rather than asserting it: a commented-outos.getenv("X")never reaches the AST, a string that merely spells one out parses as aConstant, andself.environ.get("X")fails the exact-base match. All three were added to a file at once and the test stayed green.Mutation-proven: adding
os.getenv("ZZ_PROBE_VAR")totools/safety.pyproducesand removing it returns to green. It also failed against the real bug before the fix, naming all 16 variables.
The allow-list is a dict of name → reason, not a bare set, so an entry cannot be added without recording why. A second test fails if an allow-listed name ever does get documented, forcing the entry's removal. Three anti-vacuity guards: an empty scrape is an error, a known variable must be found, and every discovered name must be accounted for.
Test Configuration
pytest tests/ -vgoes 162 → 164 passed, 2 skipped.flake8clean.black --check .fails identically before and after — 67 files on a cleanmain, pre-existing and untouched; my new file is Black-clean, so the unchanged-count rose 14 → 15. Thetest-collectors,test-toolsanddocsjob commands all pass.Checklist
Breaking Changes
None. Documentation and one new test file; no runtime code changed.
Additional Notes
Two behaviour bugs surfaced while doing this. Both are filed separately rather than fixed here, since each changes how the server starts:
Both are demonstrated in their issues by driving the real CLI, not inferred from reading the code. They change what this PR could honestly write in
.env.example:FASTMCP_HOST/FASTMCP_PORTship commented out with the hazard noted, because a.env.examplepeople copy verbatim would otherwise manufacture #40 for every user; andHOST/PORT/UVICORN_WORKERScarry a caveat that they must be exported rather than set in.env.One more thing worth knowing, not acted on:
LOG_LEVEL,PAGERDUTY_TOKEN,PAGERDUTY_SERVICE_IDand the threeAZURE_*credentials are in.env.examplebut read by no Python code — presumably by SDKs or unimplemented features. The new test deliberately does not assert that direction, since it would demand deleting live documentation.Generated by Claude Opus 5 (brief, implementation, review)