Skip to content

fix: check --env flags when validating API keys during deploy#292

Merged
inFocus7 merged 5 commits intoagentregistry-dev:mainfrom
optimus-fulcria:fix/deploy-env-flag
Mar 11, 2026
Merged

fix: check --env flags when validating API keys during deploy#292
inFocus7 merged 5 commits intoagentregistry-dev:mainfrom
optimus-fulcria:fix/deploy-env-flag

Conversation

@optimus-fulcria
Copy link
Copy Markdown
Contributor

@optimus-fulcria optimus-fulcria commented Mar 6, 2026

Description

  • Adds --env / -e flag to arctl agent deploy for passing environment variables (KEY=VALUE)
  • validateAPIKey() now checks --env values before falling back to OS environment
  • buildDeployConfig() includes all --env entries in the deployment config, with flag values taking precedence over OS env
  • Fixes the reported issue where arctl agent deploy myagent --env GOOGLE_API_KEY=somekey failed with "required API key not set"
  • Adds --env / -e flag to arctl agent run for passing environment variables (KEY=VALUE) (for command consistency)
  • Updated agent run tests to verify behavior.

Fixes #151

/kind fix
Add missing `--env` flag for `arctl agent deploy` to allow setting environment variables on the agent deployment.

Validation Steps

# assuming you don't have GOOGLE_API_KEY env set already...

# agent deploy test
go run cmd/cli/main.go agent init adk python dice
go run cmd/cli/main.go agent build dice
go run cmd/cli/main.go agent publish dice
go run cmd/cli/main.go agent deploy dice # hit error
go run cmd/cli/main.go agent deploy dice --env GOOGLE_API_KEY=test # works

# agent run test
go run cmd/cli/main.go agent init adk python dice
go run cmd/cli/main.go agent build dice
go run cmd/cli/main.go agent run dice # hit error
go run cmd/cli/main.go agent run dice --env GOOGLE_API_KEY=test # pass

Test plan

  • New TestValidateAPIKey_WithExtraEnv (6 cases): extra env, OS env, missing, precedence, nil fallback, unknown provider
  • New TestBuildDeployConfig_WithEnvOverrides (5 cases): override inclusion, precedence, OS fallback, telemetry, absent keys
  • All existing agent CLI tests pass

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@inFocus7 inFocus7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manually validated (just small test that it works), unit tests are good for sanity too, just had very minor nitpicks

Optimus (AI Agent) and others added 3 commits March 11, 2026 11:41
…gentregistry-dev#151)

`arctl agent deploy --env GOOGLE_API_KEY=somekey` now correctly uses the
provided key instead of failing with "required API key not set". The --env
flag values are checked before falling back to OS environment variables,
and all --env entries are included in the deployment config.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Fabian Gonzalez <[email protected]>
@github-actions
Copy link
Copy Markdown

You already have 3 pull requests open. Please consider working on getting the existing ones merged before opening new ones. Thanks!


// Parse --env flags into a map
envMap := make(map[string]string)
for _, e := range envFlags {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inFocus7 there's a parseEnvFlags in agent/run.go -- would it make sense to pull that out into some util/common file and then re-use it here too?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense. I moved it to a new internal/cli/utils/utils.go file, since this is specific for cli usage. If we think it'll be used elsewhere, i can move it to the pre-existing general internal/utils/utils.go pkg.

Signed-off-by: Fabian Gonzalez <[email protected]>
@peterj peterj enabled auto-merge March 11, 2026 17:05
@inFocus7 inFocus7 disabled auto-merge March 11, 2026 18:56
@inFocus7 inFocus7 enabled auto-merge March 11, 2026 19:33
@inFocus7 inFocus7 added this pull request to the merge queue Mar 11, 2026
Merged via the queue into agentregistry-dev:main with commit 1c38dcd Mar 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arctl agent deploy ignores the --env setting for the api key

3 participants