feat(config): warn on config keys this version does not use - #786
Merged
Conversation
Viper ignores unknown keys silently, so a setting removed or renamed in a past release stays in config.yaml looking live while having no effect. The value can be edited, the service restarted, and nothing changes — with no signal that the key is dead. Decodes a throwaway copy with mapstructure's ErrorUnused and logs the result. Warns rather than fails: rejecting unknown keys would break startup for anyone whose config still carries a retired setting. Example against a real config, which reports one removed key and two renamed ones the operator had not noticed: 'import' has invalid keys: max_import_connections 'rclone' has invalid keys: read_chunk_size, read_chunk_size_limit Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Looking at this PR now, it was probably overkill.. should of just removed the unused keys instead. But I was chasing tweaking a setting that had no effect for a while.. so it warranted a PR to improve the logging on it. |
javi11
approved these changes
Jul 21, 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.
Viper ignores unknown keys silently, so a setting removed or renamed in a past release stays in
config.yamllooking live while having no effect. The value can be edited, the service restarted, and nothing changes — with no signal the key is dead.This decodes a throwaway copy with mapstructure's
ErrorUnusedand logs the result. It warns rather than fails: rejecting unknown keys would break startup for anyone whose config still carries a retired setting.Real example
Run against an existing config, it reported one removed key and two renamed ones the operator had not noticed:
max_import_connectionswas removed in #763 in favour ofmax_concurrent_imports;read_chunk_size/read_chunk_size_limitwere renamed tovfs_read_chunk_size/vfs_read_chunk_size_limit. In that config the rclone values had been silently inert since the rename.Scope
+19 lines in
internal/config/manager.go, no deletions — one helper and two call sites (LoadConfigandReloadConfig, both afterReadInConfig).manager.gois not gofmt-clean upstream, so it was deliberately left unformatted to keep the diff to the change itself.Tests
TestWarnUnknownConfigKeys_ReportsRetiredKey— a retired key is named in the warningTestWarnUnknownConfigKeys_SilentOnValidConfig— a valid config warns nothingThe first fails if
ErrorUnusedis disabled.