Make error logged/raised from has_option_in_help more accurate#2943
Make error logged/raised from has_option_in_help more accurate#2943schaefi merged 1 commit intoOSInside:mainfrom
Conversation
If I'm following this code correctly, we're not raising here because we "could not parse" the output. We're raising because we parsed it and it did not have the flag we were looking for. Signed-off-by: Adam Williamson <awilliam@redhat.com>
In OSInside#2921 , based on the commit message and the fact that the code uses an `if`, it's pretty clear the use of `dracut --printconfig` is meant to be conditional. But setting the misleadingly-named `raise_on_error` to `True` means it isn't. `raise_on_error` makes `has_option_in_help` raise an exception if it *fails* - doesn't find the specified flag - not if it *errors*. Since it does not handle the exception, this code crashes if dracut does not have the argument: https://koji.fedoraproject.org/koji/taskinfo?taskID=141808928 DEBUG util.py:459: [ ERROR ]: 06:03:28 | KiwiCommandCapabilitiesError: Could not parse dracut output I've sent OSInside#2943 to make the message less of a lie, and this makes us stop crashing if the arg isn't available. Signed-off-by: Adam Williamson <awilliam@redhat.com>
In OSInside#2921 , based on the commit message and the fact that the code uses an `if`, it's pretty clear the use of `dracut --printconfig` is meant to be conditional. But setting the misleadingly-named `raise_on_error` to `True` means it isn't. `raise_on_error` makes `has_option_in_help` raise an exception if it *fails* - doesn't find the specified flag - not if it *errors*. Since it does not handle the exception, this code crashes if dracut does not have the argument: https://koji.fedoraproject.org/koji/taskinfo?taskID=141808928 DEBUG util.py:459: [ ERROR ]: 06:03:28 | KiwiCommandCapabilitiesError: Could not parse dracut output I've sent OSInside#2943 to make the message less of a lie, and this makes us stop crashing if the arg isn't available. Signed-off-by: Adam Williamson <awilliam@redhat.com>
In OSInside#2921 , based on the commit message and the fact that the code uses an `if`, it's pretty clear the use of `dracut --printconfig` is meant to be optional. But setting the misleadingly-named `raise_on_error` to `True` means it isn't. `raise_on_error` makes `has_option_in_help` raise an exception if it *fails* - doesn't find the specified flag - not if it *errors*. Since it does not handle the exception, this code crashes if dracut does not have the argument: https://koji.fedoraproject.org/koji/taskinfo?taskID=141808928 DEBUG util.py:459: [ ERROR ]: 06:03:28 | KiwiCommandCapabilitiesError: Could not parse dracut output I've sent OSInside#2943 to make the message less of a lie, and this makes us stop crashing if the arg isn't available. Signed-off-by: Adam Williamson <awilliam@redhat.com>
|
Hmm, so there's history here. Before #2159 , this did behave as the message implies - the exception was only raised if the command exited non-zero. However, in #2159 @schaefi changed it, on the basis that some commands might return non-zero when printing a usage message. He kept the exception raising behavior around but changed it to "raise an exception if the argument isn't present", not "raise an exception if the command exited non-zero"; he updated the docstring to describe this accurately, but not the exception message itself. I'm not sure if the behavior is actually useful as it currently exists? Maybe we should just get rid of it? Only one thing sets this to True, and it appears to be a bug - #2944 changes it to False. |
|
@AdamWill Thanks I like the new message 👍 |
right I remember that |
If I'm following this code correctly, we're not raising here because we "could not parse" the output. We're raising because we parsed it and it did not have the flag we were looking for.