Skip to content

node/cli: fix dotted CLI flags ignored in TOML/YAML config files#19974

Merged
anacrolix merged 1 commit intomainfrom
anacrolix/staticpeers-param-toml
Mar 18, 2026
Merged

node/cli: fix dotted CLI flags ignored in TOML/YAML config files#19974
anacrolix merged 1 commit intomainfrom
anacrolix/staticpeers-param-toml

Conversation

@anacrolix
Copy link
Copy Markdown
Contributor

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:

# 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.

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.
@anacrolix
Copy link
Copy Markdown
Contributor Author

Probably ignore this. I think it's not of value, I'll close shortly when I confirm.

@anacrolix anacrolix marked this pull request as ready for review March 18, 2026 06:02
@anacrolix
Copy link
Copy Markdown
Contributor Author

Nope, looks like it's correct.

@anacrolix anacrolix merged commit a094862 into main Mar 18, 2026
49 of 50 checks passed
@anacrolix anacrolix deleted the anacrolix/staticpeers-param-toml branch March 18, 2026 08:58
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.
AskAlexSharov pushed a commit that referenced this pull request Mar 23, 2026
…es (#20069)

Backport of #19974 to release/3.4.

Fixes dotted CLI flags being ignored when specified in TOML/YAML config
files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"staticpeers" param is not supported in toml config

2 participants