From 8c47726a8d6a670b7fc2848b253974f1618f94f6 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Fri, 14 Aug 2026 23:43:16 +0200 Subject: [PATCH] lib.App: Fix crash on invalid log options The --log-level and --log-flags options are added without a type converter, so argparse never validates their values. _build_parser() then hands the raw string to set_log_level() and set_log_flags() during its first parse, and an unparseable value such as "INVALID" crashes __init__() with a raw ValueError traceback instead of a usage error. Pass type = parse_log_level() and type = parse_log_flags() when adding the options, so that argparse reports invalid values with the standard usage error and exit status 2. argparse only applies the converter to command-line strings, so the int and LogFlag defaults are unaffected. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/App.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index de0289a6..52cd4f15 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -35,10 +35,16 @@ class App: # export def _add_arguments(self, parser: ArgumentParser) -> None: self.__parser.add_argument( - '--log-flags', help = 'Log flags', default = self.__default_log_flags + '--log-flags', + help = 'Log flags', + default = self.__default_log_flags, + type = parse_log_flags, ) self.__parser.add_argument( - '--log-level', help = 'Log level', default = self.__default_log_level + '--log-level', + help = 'Log level', + default = self.__default_log_level, + type = parse_log_level, ) self.__parser.add_argument( '--log-file', help = 'Log file', default = self.__default_log_file