Skip to content

fix: expand env vars when loading ov.conf JSON config files#908

Merged
qin-ctx merged 2 commits intovolcengine:mainfrom
itlackey:fix/expand-env-vars-in-config-loading
Mar 24, 2026
Merged

fix: expand env vars when loading ov.conf JSON config files#908
qin-ctx merged 2 commits intovolcengine:mainfrom
itlackey:fix/expand-env-vars-in-config-loading

Conversation

@itlackey
Copy link
Copy Markdown
Contributor

@itlackey itlackey commented Mar 24, 2026

This pull request enhances configuration file handling across several modules by supporting environment variable expansion within JSON config files. This allows for greater flexibility, especially in containerized or variable deployment environments. The changes ensure that any $VAR or ${VAR} placeholders in config files are replaced with their environment values before parsing, and this logic is consistently applied in all relevant config loading and validation functions.

Configuration loading improvements:

  • Updated config file loaders in bot/vikingbot/config/loader.py, openviking_cli/utils/config/config_loader.py, and openviking_cli/utils/config/open_viking_config.py to expand environment variables in JSON files before parsing, enabling dynamic configuration via environment variables. [1] [2] [3]
  • Added import os where necessary to support environment variable expansion. [1] [2]

CLI diagnostics enhancements:

  • Modified all config file reads in openviking_cli/doctor.py (check_config, check_embedding, check_vlm, check_disk) to expand environment variables before loading JSON, ensuring that diagnostics reflect the effective configuration. [1] [2] [3] [4]

Closes #909

Apply os.path.expandvars() to raw config text before JSON parsing in all
config-loading code paths, so that $VAR and ${VAR} placeholders in ov.conf
are resolved from the environment. This is especially useful for container
deployments where secrets are injected as environment variables.

Files changed:
- openviking_cli/utils/config/config_loader.py: load_json_config()
- openviking_cli/utils/config/open_viking_config.py: _load_from_file()
- openviking_cli/doctor.py: check_config(), check_embedding(), check_vlm(), check_disk()
- bot/vikingbot/config/loader.py: load_config() (already had this, no change)

The server config path (openviking/server/config.py -> load_server_config)
delegates to load_json_config() and is covered by the fix above.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 24, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@MaojiaSheng
Copy link
Copy Markdown
Collaborator

some conflicts need to be resolved

# Conflicts:
#	openviking_cli/doctor.py
@qin-ctx qin-ctx merged commit 41a2609 into volcengine:main Mar 24, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 24, 2026
zeattacker pushed a commit to zeattacker/OpenViking that referenced this pull request Mar 25, 2026
…ne#908)

Cherry-pick from upstream 41a2609. Excluded doctor.py (depends on
ov doctor command not yet in our tree).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Environment variable values not applied when loading configuration

4 participants