Skip to content

fix(config): handle empty config.yaml files - #1204

Open
aduoge wants to merge 1 commit into
volcengine:mainfrom
aduoge:fix/empty-config-yaml
Open

aduoge wants to merge 1 commit into
volcengine:mainfrom
aduoge:fix/empty-config-yaml

Conversation

@aduoge

@aduoge aduoge commented Nov 3, 2026

Copy link
Copy Markdown

veadk.config looks for a config.yaml (via find_dotenv(usecwd=True)) and passes it to set_envs at import time. yaml.safe_load returns None for an empty file, a comment-only file or a bare ---, and flatten_dict(None) then raises:

AttributeError: 'NoneType' object has no attribute 'items'

So with an empty or placeholder config.yaml in the working directory, or in any parent directory, import veadk.config fails, and so does everything that imports it, e.g. from veadk import Agent. That's an easy state to end up in when configuration comes from environment variables only.

set_envs now treats a None document as an empty mapping. Non-empty configs, including nested ones, and the precedence of existing environment variables are unchanged.

Tests

New tests/utils/test_empty_config.py: three empty-document variants, plus a nested-config/env-precedence check. On main: 3 failed, 1 passed. On this branch: 4 passed.

I also checked the import path end to end: in a temp directory containing an empty config.yaml, python -c "import veadk.config" raises the error above on main and imports cleanly on this branch.

Full suite (uv run --extra dev pytest -n 4 -m "not codex_smoke and not piagent_smoke"): 26 failed, 2 errors, 8053 passed. The same 28 failures/errors occur on unmodified main in my environment (tests/runtime/codex/*, tests/cloud/test_harness_app_contract.py, tests/frontend/test_migration_delivery_recovery.py, tests/runtime/test_self_host_sandbox_*), so none are new. Ruff 0.11.12 (the pre-commit version) check and format --check are clean on the changed files.

yaml.safe_load returns None for an empty file, a comment-only file or a
bare document marker. set_envs passed that to flatten_dict, which failed
with AttributeError, and since veadk.config calls set_envs at import
time, importing veadk failed whenever such a config.yaml was found.
Treat a None document as an empty mapping.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant