fix(config): use read_raw_config() in migrations to prevent expanding defaults (#40821) - #53132
Merged
kshitijk4poor merged 1 commit intoJun 26, 2026
Conversation
kshitijk4poor
force-pushed
the
salvage/40821-migration-raw-config
branch
from
June 26, 2026 15:44
6a309bd to
f465476
Compare
Contributor
|
This was referenced Jun 26, 2026
Closed
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
Config migration no longer expands the user's curated config.yaml into a ~13KB defaults dump — migrations now use
read_raw_config()instead ofload_config()so only the user's actual config is read, modified, and written back.Root cause (#40821)
migrate_config()usedload_config()which deep-mergesDEFAULT_CONFIG(73 keys) with the user's config. Whensave_config()wrote the result, the user's ~950-byte file became a ~13KB defaults dump — comments and structure lost. Thecustom_providerskey appeared "dropped" because the v11→v12 migration moves it toproviders(dict), but the file expansion made this hard to notice.Changes
hermes_cli/config.py: 7load_config()calls inmigrate_config()changed toread_raw_config(). This prevents DEFAULT_CONFIG from being merged in during migration, sosave_config()only writes the user's actual config plus migration changes.tests/hermes_cli/test_config.py: existingtest_migrate_adds_discord_channel_prompts_defaultupdated to assertchannel_promptsis NOT in the file (it's a DEFAULT_CONFIG value that shouldn't be expanded). New regression testtest_migrate_preserves_custom_providers_and_no_defaults_dumpverifies: (1)custom_providersis migrated toprovidersdict, (2) file stays under 5KB (not a defaults dump).Validation
scripts/run_tests.sh tests/hermes_cli/test_config.py— 107/107 passed.Salvaged from #40921 by @kyssta-exe. Chosen over #40981 (@iamlukethedev) which addresses the save_config side — but the migration path is the root cause, and fixing it there is the correct approach. #40981's "preserve unknown fields" approach would also work but is more invasive and addresses a non-bug (
custom_providersis intentionally migrated, not lost).Closes #40821