You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve error reporting when non mandatory options are misconfigured or incorrectly specified at runtimeΒ #1245
If a command is invoked without any option, the warning is logged. Which is not consistent if command is invoked with and option without value (there is no warning message).
shell:>hello
11:32:19.249 [main] WARN o.s.s.c.c.a.MethodInvokerCommandAdapter - No value provided for optional option '--name' and no default value specified.
Hello !
shell:>hello --name
Hello !
shell:>hello -n
Hello !
If option is specified with a short or long name with space before the value, it's not recognized.
shell:>hello --name Paul
Hello !
shell:>hello -n Paul
Hello !
The value is recognized only if specified with equal sign.
If a command is invoked without any option, the warning is logged. Which is not consistent if command is invoked with and option without value (there is no warning message).
I think those are different things: 1) not providing an optional option not having a default value vs 2) providing an option with incorrect syntax (missing value)
is a command configuration problem and should fail fast at command configuration time (introspection time, ie in CommandFactoryBean)
is a command usage problem which can happen at runtime (command invoking time, ie in MethodInvokerCommandAdapter).
I think there is a room for improvement here, but this is not blocking for 4.0 GA.
If option is specified with a short or long name with space before the value, it's not recognized.
The value is recognized only if specified with equal sign.
Option values without an equal sign are not recognized
Since this is not supported in the default parser as explained, I am changing the title of this issue to focus on issue 1): improve error reporting when non mandatory options are not specified or incorrectly specified.
changed the title [-]Option values without an equal sign are not recognized[/-][+]Improve error reporting when non mandatory options are misconfigured or not incorrectly specified at runtime[/+]on Dec 26, 2025
The default parser only supports key=value pairs. This is mentioned in the docs here
@czpilar While thinking about this, I improved the default parser to support the --key value / -k value syntax in addition to the --key=value / -k=valule form, see #1248.
This works way better with command completion now! I think the updated DefaultCommandParserTests suite is fairly complete, but I might have missed a corner case or two at this time of the day night π . I will retest this with a fresh head again before GA. Any feedback is welcome!
@fmbenhassine Thank you for improving the default parser β it definitely works much better with completion now.
I realized that after fixing the completion issue in #1246, I completely missed the case where a key=value pair is already present on the command line. Because of that, I opened a new PR to address this scenario. Please take a look.
changed the title [-]Improve error reporting when non mandatory options are misconfigured or not incorrectly specified at runtime[/-][+]Improve error reporting when non mandatory options are misconfigured or incorrectly specified at runtime[/+]on Dec 28, 2025
If a command is invoked without any option, the warning is logged. Which is not consistent if command is invoked with and option without value (there is no warning message).
If an option specifies only a shortName and no default value, as in the following example:
@Option(shortName = 'n') Stringfirst
The warning message incorrectly reports the shortName with a double dash (e.g., --n). It should be -n.
shell:>hello
13:47:31.726 [main] WARN o.s.s.c.c.a.MethodInvokerCommandAdapter - No value provided for optional option '--n' and no default value specified.
Hello !
Also, not providing a default value for optional options is, in my opinion, a valid scenario, as I may want the option value to be null, or to use the Java default value in the case of primitive types, without showing any warning message.
is a command configuration problem and should fail fast at command configuration time (introspection time, ie in CommandFactoryBean)
is not up-to-date anymore after db567c2. In fact, now if the user defines a non-mandatory option without a default value, the option will be assigned the default value in Java for primitives types, and null for non primitive types.
Also, not providing a default value for optional options is, in my opinion, a valid scenario, as I may want the option value to be null, or to use the Java default value in the case of primitive types, without showing any warning message.
@czpilar I agree, now that #1262 , #1304 are #1314 resolved. Since there is no error nor warning anymore in this case, I am closing this issue and related PR that were seeking to "Improve error reporting".
Activity
fmbenhassine commentedon Dec 26, 2025
I think those are different things: 1) not providing an optional option not having a default value vs 2) providing an option with incorrect syntax (missing value)
CommandFactoryBean)MethodInvokerCommandAdapter).I think there is a room for improvement here, but this is not blocking for 4.0 GA.
The default parser only supports key=value pairs. This is mentioned in the docs here: https://docs.spring.io/spring-shell/reference/4.0-SNAPSHOT/commands/syntax.html
EDIT:
Since this is not supported in the default parser as explained, I am changing the title of this issue to focus on issue 1): improve error reporting when non mandatory options are not specified or incorrectly specified.
[-]Option values without an equal sign are not recognized[/-][+]Improve error reporting when non mandatory options are misconfigured or not incorrectly specified at runtime[/+]fmbenhassine commentedon Dec 27, 2025
@czpilar While thinking about this, I improved the default parser to support the
--key value/-k valuesyntax in addition to the--key=value/-k=valuleform, see #1248.This works way better with command completion now! I think the updated
DefaultCommandParserTestssuite is fairly complete, but I might have missed a corner case or two at this time of thedaynight π . I will retest this with a fresh head again before GA. Any feedback is welcome!czpilar commentedon Dec 27, 2025
@fmbenhassine Thank you for improving the default parser β it definitely works much better with completion now.
I realized that after fixing the completion issue in #1246, I completely missed the case where a
key=valuepair is already present on the command line. Because of that, I opened a new PR to address this scenario. Please take a look.TusharSamaniya commentedon Dec 28, 2025
Can i also work with #1245 issue
[-]Improve error reporting when non mandatory options are misconfigured or not incorrectly specified at runtime[/-][+]Improve error reporting when non mandatory options are misconfigured or incorrectly specified at runtime[/+]fmbenhassine commentedon Dec 28, 2025
@TusharSamaniya Sure! Contributions are welcome. Thank you for your offer to help!
czpilar commentedon Dec 31, 2025
Regardig:
If an option specifies only a
shortNameand no default value, as in the following example:The warning message incorrectly reports the
shortNamewith a double dash (e.g.,--n). It should be-n.Also, not providing a default value for optional options is, in my opinion, a valid scenario, as I may want the option value to be
null, or to use the Java default value in the case of primitive types, without showing any warning message.jayychoi commentedon Jan 24, 2026
Hi @TusharSamaniya, how's the work going? May I work on this issue if you don't mind?
Improve error reporting when non mandatory options are misconfigured
fmbenhassine commentedon Apr 8, 2026
I think what I said previously here:
is not up-to-date anymore after db567c2. In fact, now if the user defines a non-mandatory option without a default value, the option will be assigned the default value in Java for primitives types, and
nullfor non primitive types.@czpilar I agree, now that #1262 , #1304 are #1314 resolved. Since there is no error nor warning anymore in this case, I am closing this issue and related PR that were seeking to "Improve error reporting".