Persist config backward-compat migrations to load path - #5416
Merged
Merged
Conversation
Loading a config from an explicit path (PathProvider, LoadOrCreate- ConfigWithPath) that needed a backward-compatibility migration wrote the migrated result to the default xdg path instead of the path it was loaded from. applyBackwardCompatibility called the path-agnostic save(), which always resolves to getConfigPath(). For tests this clobbered the developer's real config file whenever a PathProvider loaded a temp config with a secrets provider set but setup_completed false, defeating the isolation added for #894. It was also a latent correctness bug for any path-based load in production. Thread the load path through applyBackwardCompatibility and persist via saveToPath(configPath). Remove the now-unused save() helper. Closes #894 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5416 +/- ##
==========================================
- Coverage 68.76% 68.75% -0.01%
==========================================
Files 629 629
Lines 63922 63920 -2
==========================================
- Hits 43958 43951 -7
- Misses 16707 16714 +7
+ Partials 3257 3255 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChrisJBurns
approved these changes
Jun 1, 2026
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.
Summary
Loading a config from an explicit path (
PathProvider,LoadOrCreateConfigWithPath) that needed a backward-compatibility migration wrote the migrated result to the default XDG path instead of the path it was loaded from.applyBackwardCompatibilitycalled the path-agnosticsave(), which always resolves togetConfigPath().For tests this clobbered the developer's real config file whenever a
PathProviderloaded a temp config with a secrets provider set butsetup_completedfalse. This defeated the test isolation that #894 was supposed to deliver: running the full unit suite (e.g.pkg/client'sTestSuccessfulClientConfigOperationsandTestFindClientConfigs) silently overwrote~/Library/Application Support/toolhive/config.yamlwith a test fixture. It was also a latent correctness bug for any path-based load in production.applyBackwardCompatibilityand persist viasaveToPath(configPath)so migrations stay on the path the config was loaded from.save()helper.pkg/configregression test that pointsgetConfigPathat a sentinel and asserts a migration-triggering load never touches the default path.Closes #894
Type of change
Test plan
task test)task lint-fix)Manual: backed up the real config, ran
go test -count=1 ./pkg/config/... ./pkg/client/..., and confirmed the config file hash was unchanged afterward. Verified the new regression test fails on the pre-fix code and passes with the fix. Confirmed the fulltask testsuite leaves the real config byte-identical.Does this introduce a user-facing change?
No. There are no production callers of
NewPathProvidertoday, so the visible impact was limited to test pollution. The fix also closes the latent production bug for any future path-based load.Special notes for reviewers
While verifying the full suite I found a separate, pre-existing test-isolation gap unrelated to this change:
pkg/skills/client'sTestNewDefaultClient/falls_back_to_default_URL_when_env_is_emptyfails locally when athv/Desktop server is running, because it stubs the env var but not server discovery. CI is unaffected. I'll address that in a follow-up PR.🤖 Generated with Claude Code