Skip to content

test: keep the developer's user-wide config out of every test - #486

Merged
HananKavitzAmat merged 1 commit into
chunkhound:mainfrom
fstrasz:fix/tests-ignore-user-global-config
Nov 8, 2026
Merged

HananKavitzAmat merged 1 commit into
chunkhound:mainfrom
fstrasz:fix/tests-ignore-user-global-config

Conversation

@fstrasz

@fstrasz fstrasz commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Config() merges the first file it finds among Config.get_global_config_candidates() (~/.config/chunkhound/chunkhound.json and the others). A test that builds a Config without an embedding section therefore inherits whatever embedding provider the developer's machine is configured with.

On a machine whose global config selects voyageai and supplies the key through VOYAGE_API_KEY, the realtime tests that call create_services fail in EmbeddingProviderFactory.create_provider:

ValueError: Incomplete configuration for voyageai provider. Missing: api_key (set VOYAGE_API_KEY or CHUNKHOUND_EMBEDDING__API_KEY)

With the key exported, #453 fills it in and the same tests build a real Voyage provider instead. Neither happens in CI, which has no global config, so the suite passes there and fails (or reaches a paid API) on a configured developer machine.

Fix

A session-scoped autouse fixture in tests/conftest.py pins CHUNKHOUND_GLOBAL_CONFIG_FILE to an existing empty {} file, so the global layer is empty for every test, as it is in CI. Tests that exercise global-config discovery already set or delete the variable themselves (tests/remote_config/conftest.py's _isolate, clean_environment, test_config_integration.py), so they are unaffected.

I changed the tests, not config resolution: reading the user-wide config is correct product behaviour, and the leak is that the tests depend on the machine they run on.

Evidence

Windows 11, Python 3.13, this branch, global config selecting voyageai, VOYAGE_API_KEY unset, realtime set (tests/realtime + tests/test_realtime_*.py):

result
without the fixture 20 failed, 71 passed, 34 skipped, 47 errors (67 api_key errors)
with the fixture 138 passed, 34 skipped

tests/test_config*.py + tests/remote_config fail the same 5 tests with and without the fixture (pre-existing on Windows).

🤖 Generated with Claude Code

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]>
@HananKavitzAmat

Copy link
Copy Markdown
Collaborator

looks good

@HananKavitzAmat
HananKavitzAmat added this pull request to the merge queue Nov 8, 2026
Merged via the queue into chunkhound:main with commit 98be86f Nov 8, 2026
25 checks passed
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.

2 participants