node/cli: fix dotted CLI flags ignored in TOML/YAML config files#19974
Merged
node/cli: fix dotted CLI flags ignored in TOML/YAML config files#19974
Conversation
TOML nested tables like: [sentinel] staticpeers = ["enode://..."] and dotted keys like: sentinel.staticpeers = ["enode://..."] both parse into a nested map[string]any, not a flat key "sentinel.staticpeers". This caused all dotted CLI flags (sentinel.*, http.*, etc.) to be silently ignored when set via a TOML config file. Fix by recursively flattening the parsed config map before applying it to the CLI context. Also handles YAML's map[any]any type from gopkg.in/yaml.v2 so both formats benefit from the fix.
Contributor
Author
|
Probably ignore this. I think it's not of value, I'll close shortly when I confirm. |
Contributor
Author
|
Nope, looks like it's correct. |
AskAlexSharov
approved these changes
Mar 18, 2026
anacrolix
added a commit
that referenced
this pull request
Mar 22, 2026
) ## Summary Fixes #17388. When a TOML config file uses nested tables or dotted keys for flags that contain a `.` in their name (e.g. `sentinel.staticpeers`, `http.addr`), the `pelletier/go-toml` parser produces a nested `map[string]any` rather than a flat key `"sentinel.staticpeers"`. This caused all such flags to be silently ignored. **Before:** `[sentinel]\nstaticpeers = [...]` → parsed as `{"sentinel": {"staticpeers": [...]}}` → key `"sentinel"` not found as a CLI flag, silently dropped. **After:** nested maps are recursively flattened into dot-separated keys before applying them to the CLI context, so both of these TOML forms work correctly: ```toml # Dotted key form sentinel.staticpeers = ["enode://..."] # Nested table form [sentinel] staticpeers = ["enode://..."] ``` The same fix applies to YAML config files via `gopkg.in/yaml.v2`'s `map[any]any` type. Note: flat keys without dots (e.g. `staticpeers = [...]`) already worked correctly and continue to do so.
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
Fixes #17388.
When a TOML config file uses nested tables or dotted keys for flags that contain a
.in their name (e.g.sentinel.staticpeers,http.addr), thepelletier/go-tomlparser produces a nestedmap[string]anyrather than a flat key"sentinel.staticpeers". This caused all such flags to be silently ignored.Before:
[sentinel]\nstaticpeers = [...]→ parsed as{"sentinel": {"staticpeers": [...]}}→ key"sentinel"not found as a CLI flag, silently dropped.After: nested maps are recursively flattened into dot-separated keys before applying them to the CLI context, so both of these TOML forms work correctly:
The same fix applies to YAML config files via
gopkg.in/yaml.v2'smap[any]anytype.Note: flat keys without dots (e.g.
staticpeers = [...]) already worked correctly and continue to do so.