Repository navigation
fix(config): apply VOYAGE_API_KEY after merging config layers - #453
Merged
HananKavitzAmat merged 1 commit intoOct 25, 2026
Merged
Conversation
The VOYAGE_API_KEY fallback ran inside EmbeddingConfig.load_from_env, where only environment values are known. When the voyageai provider came from .chunkhound.json, a global config or --provider, the fallback never saw it, and indexing failed with 'Missing required configuration: embedding.api_key (set VOYAGE_API_KEY ...)' although the variable was set. Apply the fallback once more after all layers are merged. A key from any layer still wins, and other providers are not affected. Fixes #448 Signed-off-by: mayuriphad <[email protected]>
Collaborator
|
This looks good to me. |
fstrasz
added a commit
to fstrasz/chunkhound
that referenced
this pull request
Nov 7, 2026
Config() merges the first file among get_global_config_candidates()
(~/.config/chunkhound/chunkhound.json and friends). A test that builds a
Config without an embedding section therefore inherits whatever provider
the machine is configured with. On a machine whose global config selects
voyageai with the key supplied by VOYAGE_API_KEY, 47 realtime tests error
and 21 fail in EmbeddingProviderFactory ("Missing: api_key"). With chunkhound#453
applied and the key set, the same tests instead build a real Voyage
provider. Neither happens in CI, which has no global config.
A session-scoped autouse fixture pins CHUNKHOUND_GLOBAL_CONFIG_FILE to an
existing empty file, so the global layer is empty for every test. Tests
that exercise global-config discovery already set or delete the variable
themselves (remote_config's _isolate, clean_environment,
test_config_integration).
Realtime set on Windows with that global config: 21 failed / 71 passed /
34 skipped / 47 errors before, 139 passed / 34 skipped after. The config
tests fail the same 5 tests with and without the fixture.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fstrasz
pushed a commit
to fstrasz/chunkhound
that referenced
this pull request
Nov 7, 2026
…ound#453) The VOYAGE_API_KEY fallback ran inside EmbeddingConfig.load_from_env, where only environment values are known. When the voyageai provider came from .chunkhound.json, a global config or --provider, the fallback never saw it, and indexing failed with 'Missing required configuration: embedding.api_key (set VOYAGE_API_KEY ...)' although the variable was set. Apply the fallback once more after all layers are merged. A key from any layer still wins, and other providers are not affected. Fixes chunkhound#448 Signed-off-by: mayuriphad <[email protected]> (cherry picked from commit 829ec58)
huangyingting
pushed a commit
to repomesh/chunkhound
that referenced
this pull request
Nov 9, 2026
…ound#486) Config() merges the first file among get_global_config_candidates() (~/.config/chunkhound/chunkhound.json and friends). A test that builds a Config without an embedding section therefore inherits whatever provider the machine is configured with. On a machine whose global config selects voyageai with the key supplied by VOYAGE_API_KEY, 47 realtime tests error and 21 fail in EmbeddingProviderFactory ("Missing: api_key"). With chunkhound#453 applied and the key set, the same tests instead build a real Voyage provider. Neither happens in CI, which has no global config. A session-scoped autouse fixture pins CHUNKHOUND_GLOBAL_CONFIG_FILE to an existing empty file, so the global layer is empty for every test. Tests that exercise global-config discovery already set or delete the variable themselves (remote_config's _isolate, clean_environment, test_config_integration). Realtime set on Windows with that global config: 21 failed / 71 passed / 34 skipped / 47 errors before, 139 passed / 34 skipped after. The config tests fail the same 5 tests with and without the fixture. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes #448
VOYAGE_API_KEYwas only used when the voyageai provider came from an environment variable. The fallback lives inEmbeddingConfig.load_from_env, which only sees env values. A provider set in.chunkhound.json, in the global config or with--provider voyageaiis merged in later, so the key was never filled in, andchunkhound indexfailed with:Config.__init__now applies the fallback once more after all layers (env, global, local,--config, CLI, kwargs) are merged. It only runs when the env layer is enabled, the merged provider isvoyageaiand no layer supplied anapi_key. An API key from any layer still takes precedence, and the openai provider never picks upVOYAGE_API_KEY. The existing env-only fallback inload_from_envis unchanged.Tests (
tests/test_config_integration.py):test_voyage_api_key_used_for_provider_from_local_config: provider from.chunkhound.jsontest_voyage_api_key_used_for_provider_from_cli:--provider voyageaitest_voyage_api_key_does_not_override_configured_keytest_voyage_api_key_not_used_for_openai_providerThe first two fail on
mainand pass with the change. On my machinetests/test_config_integration.pypasses (35 tests), and so dotests/config,tests/remote_configandtests/unit/test_embedding_config_provider_check.py(154 passed).ruff format --checkandmypyare clean onconfig.py. I'm on Windows, where thechunkhound_nativeextension can't load, so I stubbed it for these config-only tests.tests/test_smoke.pygives the same 8 failures with and without this change; they come from CLI subprocesses that need the native module.