Skip to content

feat: add startup check for GITLAB_TOKEN and GITLAB_USERNAME env vars

Klaus Wölfel requested to merge inform-gitlab-env-status into master

Add klausagent/env.py with a check_env() function that validates authentication-related environment variables at startup:

  • ANTHROPIC_API_KEY: required — raises SystemExit with a clear message if missing or empty.
  • GITLAB_TOKEN + GITLAB_USERNAME: optional — emits a warning when only one of the two is set, since both are needed for the GIT_ASKPASS helper to work. Returns gitlab_auth=True/False in the result dict.

Call check_env() from cli.py at the start of run_chat() so problems are reported before any tool servers or API clients are created.

Update run.sh comment to explain the two-layer check (bash fast-fail for the hard requirement, Python for the full check with warnings).

Add tests/test_env.py with 9 tests covering all combinations: missing key, empty key, valid key, both gitlab vars, neither, only token, only username, all vars, and the combined error+warning case.

Merge request reports