fix: forward required env vars to sre-agent container in docker-compose#209
Open
Sanjays2402 wants to merge 1 commit into
Open
fix: forward required env vars to sre-agent container in docker-compose#209Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
The sre-agent service defined in docker-compose.yaml crashes at startup because several required environment variables are never forwarded into the container: - GITHUB_OWNER, GITHUB_REPO, and GITHUB_REF are required fields on GitHubSettings (no defaults), so settings validation raises a pydantic ValidationError as soon as the container starts. - LOG_GROUP and SERVICE_NAME are required by sre_agent.run; without them the entrypoint exits with usage output and a non-zero status. - TIME_RANGE_MINUTES is optional but honoured by sre_agent.run when set, so it is plumbed through with a sensible default. Because the service uses restart: unless-stopped, this produces a crash-loop that prevents docker compose up from ever bringing up the agent, even when the missing values are present in the user shell environment or project .env file (docker compose only passes through variables listed under environment: or env_file:).
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.
What
Forward the environment variables that the
sre-agentcontainer requires to start (GITHUB_OWNER,GITHUB_REPO,GITHUB_REF,LOG_GROUP,SERVICE_NAME,TIME_RANGE_MINUTES) through thesre-agentservice'senvironment:block indocker-compose.yaml.Why
docker-compose.yamldoes not forward several environment variables that thesre-agentcontainer requires.docker composeonly passes variables that are explicitly listed in a service'senvironment:(orenv_file:) block — the user shell or project.envis not enough on its own. As a result, runningdocker compose up -dproduces a crash-loop on thesre-agentservice:GITHUB_OWNER,GITHUB_REPO,GITHUB_REFare declared as required fields onGitHubSettingsinsrc/sre_agent/core/settings.py(lines 22-35, no defaults). Settings validation raises apydantic.ValidationErroras soon assre_agent.runimports the agent.LOG_GROUPandSERVICE_NAMEare required bysre_agent/run.py::_load_request_from_args_or_env(lines 22-36). Without them the entrypoint prints a usage banner and exits withSystemExit(1).TIME_RANGE_MINUTESis optional forsre_agent.runbut is honoured when set.With
restart: unless-stopped, the container keeps restarting and the agent never comes up.How
Extend the
environment:block of thesre-agentservice so compose forwards every variable the agent needs to start:GITHUB_OWNER,GITHUB_REPO,GITHUB_REF(withmainas the default for the ref, matchingIntegrationConfig.github_ref).LOG_GROUP,SERVICE_NAME(required bysre_agent.run).TIME_RANGE_MINUTES(optional, default10, matching the CLI default).Diff: +7 / −0 in
docker-compose.yaml.Extra
No new dependencies.
Repro on current main (6fe7329):
After the fix — compose config now renders all required vars:
Notes
src/sre_agent/core/deployments/aws_ecs/ecs_tasks.py(GITHUB_OWNER/REPO/REFare set there explicitly), so compose and ECS are now consistent about what the container needs..env) beforedocker compose up, but that is the same contract compose already uses forANTHROPIC_API_KEY,SLACK_CHANNEL_ID, etc.Checklist
docker compose config; no unit-testable code change.)Type of change
Bug fix. Adjusted label on the PR panel.
MacOS tests
Not required — docker-compose YAML change only, no dependency or OS-specific behavior changes.