Skip to content

Commit e9b6987

Browse files
authored
fix: nested config priority (#5514)
1 parent 3b1fc52 commit e9b6987

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cmd/bee/cmd/cmd.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,14 @@ func (c *command) initLogger(cmd *cobra.Command) error {
373373
// nested (blockchain-rpc.endpoint) YAML forms, with nested taking precedence.
374374
func (c *command) bindBlockchainRpcConfig(cmd *cobra.Command) {
375375
for _, p := range blockchainRpcConfigPairs {
376-
// Check before registering the alias; afterwards the flat value is unreachable.
377-
if c.config.InConfig(p.flat) && c.config.InConfig(p.dotted) {
378-
c.logger.Warning("config key conflict: nested form takes precedence", "ignored", p.flat, "used", p.dotted)
379-
}
376+
nested := c.config.Get(p.dotted)
377+
conflict := c.config.InConfig(p.flat) && c.config.IsSet(p.dotted)
380378
_ = c.config.BindPFlag(p.dotted, cmd.Flags().Lookup(p.flat))
381379
c.config.RegisterAlias(p.flat, p.dotted)
380+
if conflict {
381+
c.logger.Warning("config key conflict: nested form takes precedence", "ignored", p.flat, "used", p.dotted)
382+
c.config.Set(p.dotted, nested)
383+
}
382384
}
383385
}
384386

0 commit comments

Comments
 (0)