Skip to content

feature(server,helm): support env override for api_key#830

Merged
Pangjiping merged 4 commits intoalibaba:mainfrom
sauce-git:feature/server-env-api-key-override
May 3, 2026
Merged

feature(server,helm): support env override for api_key#830
Pangjiping merged 4 commits intoalibaba:mainfrom
sauce-git:feature/server-env-api-key-override

Conversation

@sauce-git
Copy link
Copy Markdown
Contributor

@sauce-git sauce-git commented May 2, 2026

Summary

Add OPENSANDBOX_SERVER_API_KEY environment variable to override server.api_key from TOML config.

Problem

Previously, OpenSandbox only supported API key configuration via a config file. However, in environments such as Kubernetes, secrets are typically injected via environment variables, making it difficult to integrate OpenSandbox securely without additional workarounds.

Changes

  • Add _apply_env_overrides() to apply env vars after parsing
  • Define API_KEY_ENV_VAR constant for the environment variable name
  • Accept extraEnv in server Helm chart

Testing

  • Not run (explain why)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

Add OPENSANDBOX_SERVER_API_KEY environment variable to override
server.api_key from TOML config.

- Add _apply_env_overrides() to apply env vars after parsing
- Define API_KEY_ENV_VAR constant for the environment variable name
- Accept extraEnv in server Helm chart
Copilot AI review requested due to automatic review settings May 2, 2026 10:37
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 2, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5364838ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread server/opensandbox_server/config.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for overriding server.api_key via the OPENSANDBOX_SERVER_API_KEY environment variable and wires that into the server Helm chart so Kubernetes deployments can source the API key from container env instead of baking it into config.toml. It extends the server’s configuration-loading path and the chart values/template used to deploy the API service.

Changes:

  • Added API key env-override handling in server/opensandbox_server/config.py.
  • Added config tests covering env override precedence over TOML values.
  • Added extraEnv support to the opensandbox-server Helm chart so operators can inject OPENSANDBOX_SERVER_API_KEY.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
server/tests/test_config.py Adds tests for API key override behavior and TOML fallback behavior.
server/opensandbox_server/config.py Introduces the new env var constant and applies env-based config overrides after TOML parsing.
kubernetes/charts/opensandbox-server/values.yaml Adds chart values for passing additional container environment variables.
kubernetes/charts/opensandbox-server/templates/server.yaml Renders extraEnv into the server Deployment container spec.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/opensandbox_server/config.py Outdated
Comment thread server/opensandbox_server/config.py
sauce-git and others added 2 commits May 2, 2026 19:45
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Pangjiping
Copy link
Copy Markdown
Collaborator

I'm not sure what the purpose of doing this is.

@sauce-git
Copy link
Copy Markdown
Contributor Author

sauce-git commented May 2, 2026

@Pangjiping

Previously, OpenSandbox only supported API key configuration via a config file. However, in environments such as Kubernetes, secrets are typically injected via environment variables, making it difficult to integrate OpenSandbox securely without additional workarounds.

Comment thread kubernetes/charts/opensandbox-server/values.yaml Outdated
@Pangjiping Pangjiping added feature New feature or request component/server labels May 2, 2026
@Pangjiping Pangjiping self-requested a review May 2, 2026 23:48
Copy link
Copy Markdown
Collaborator

@Pangjiping Pangjiping left a comment

Choose a reason for hiding this comment

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

LGTM

@Pangjiping Pangjiping merged commit 2ff6b58 into alibaba:main May 3, 2026
38 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/server feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants