Description
Describe the bug
In the current Go implementation of the launcher, system properties provided via the -D
command-line argument (e.g., -Dnode.id=foo
) are overridden by values defined in the node.properties
file if the same key exists in both. This is a regression from the previous Python-based launcher, where command-line arguments had higher precedence and could override settings from the node.properties
file.
Steps to reproduce
- Create or modify
etc/node.properties
to include a property, for example:node.id=id_from_file
- Run the launcher with a
-D
argument for the same property but a different value:./launcher -Dnode.id=id_from_cli run
- Observe the effective
node.id
used by the application.
Expected behavior
The node.id
used by the application should be id_from_cli
, as the command-line argument should override the value from the node.properties
file.
Actual behavior
The node.id
used by the application is id_from_file
, because the values from node.properties
are applied after the command-line -D
arguments are parsed, effectively overwriting them.
Code reference
The issue likely stems from the order of operations in src/main/go/args/args.go
. The system properties from -D
flags are parsed first, and then properties from node.properties
are copied into the system properties, potentially overwriting the command-line specified values.
Specifically, this block of code:
// src/main/go/args/args.go lines 223-230
options.SystemPropertie
5A64
s, err = properties.Parse(flags.systemPropertiesOpt)
if err != nil {
return commands.UNKNOWN, nil, fmt.Errorf("provided system properties are invalid: %w", err)
}
// Copy node.config properties into system properties
for key, value := range options.NodeConfig {
options.SystemProperties[key] = value
}
This logic means that options.NodeConfig
(from node.properties
) will overwrite any identically named keys already present in options.SystemProperties
(from -D
flags).
To fix this, the -D
arguments should be applied after the node.properties
are loaded, or the copying logic should check if a key already exists from a -D
argument and not overwrite it.