Skip to content

fix(config): use read_raw_config() in migrations to prevent expanding defaults (#40821) - #53132

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/40821-migration-raw-config
Jun 26, 2026
Merged

kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/40821-migration-raw-config

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Contributor

Summary

Config migration no longer expands the user's curated config.yaml into a ~13KB defaults dump — migrations now use read_raw_config() instead of load_config() so only the user's actual config is read, modified, and written back.

Root cause (#40821)

migrate_config() used load_config() which deep-merges DEFAULT_CONFIG (73 keys) with the user's config. When save_config() wrote the result, the user's ~950-byte file became a ~13KB defaults dump — comments and structure lost. The custom_providers key appeared "dropped" because the v11→v12 migration moves it to providers (dict), but the file expansion made this hard to notice.

Changes

  • hermes_cli/config.py: 7 load_config() calls in migrate_config() changed to read_raw_config(). This prevents DEFAULT_CONFIG from being merged in during migration, so save_config() only writes the user's actual config plus migration changes.
  • tests/hermes_cli/test_config.py: existing test_migrate_adds_discord_channel_prompts_default updated to assert channel_prompts is NOT in the file (it's a DEFAULT_CONFIG value that shouldn't be expanded). New regression test test_migrate_preserves_custom_providers_and_no_defaults_dump verifies: (1) custom_providers is migrated to providers dict, (2) file stays under 5KB (not a defaults dump).

Validation

Before After
v3 config migration 13,316 bytes (defaults dump) 2,525 bytes (user config + migrations)
custom_providers migrated to providers dict (data preserved) same (unchanged behavior)
Comments/structure destroyed preserved

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_providers is intentionally migrated, not lost).

Closes #40821

@kshitijk4poor
kshitijk4poor force-pushed the salvage/40821-migration-raw-config branch from 6a309bd to f465476 Compare June 26, 2026 15:44
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jun 26, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.
Related: salvage of #40921 (identical diff, same read_raw_config()-in-migrations mechanism) and competes with #40981 (preserve-unknown-fields in save_config). #40921 is the earliest-open canonical fix for the migration-path root cause of #40821; a maintainer should pick one of this cluster.

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

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.16.0: first config write after upgrade rewrites config.yaml to expanded defaults, dropping custom_providers (distinct from #17876)

3 participants