From 9d6a648a07e49150ddf3baa1290fc89d62f29cfc Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Wed, 19 Aug 2026 22:36:24 -0700 Subject: [PATCH] fix(kconfig): surface generator errors from loadconfig ensure_env() sent the child's stdout to DEVNULL to keep this process's stdout parseable, but the generator reports missing imports with print(), so that was exactly the output being discarded. What survived was a CalledProcessError whose message repeats the argv, and the argv carries every .msg path: 9901 bytes on one line, naming no cause and no remedy. Capture both streams and, on failure, exit with the child's own output. The message names the command that failed and its exit code rather than asserting what kind of failure it was, so it stays accurate whatever the child is or why it failed. Missing empy now reports 167 bytes: loadconfig: px_generate_zenoh_topic_files.py failed (exit 1) Failed to import em: No module named 'em' You may need to install it using: pip3 install --user empy stdout stays clean on success, so callers that parse it are unaffected. Smoke tested on Ubuntu 24.04, matching the runner base: happy path returns valid JSON for --group and --group --seeders; missing empy and missing pyros-genmsg each report the cause and remedy; an unrunnable generator reports the interpreter's own "can't open file"; a child exiting non-zero with no output reports "(no output)" rather than an empty message; and a preset ZENOH_KCONFIG_TOPICS still skips the generator entirely. Assisted-by: Claude:claude-opus-5 Signed-off-by: Ramon Roche --- Tools/kconfig/loadconfig.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Tools/kconfig/loadconfig.py b/Tools/kconfig/loadconfig.py index 23a541d4c3f..6023e7a4bfa 100644 --- a/Tools/kconfig/loadconfig.py +++ b/Tools/kconfig/loadconfig.py @@ -46,10 +46,18 @@ def ensure_env(): atexit.register(shutil.rmtree, out_dir, ignore_errors=True) msg_files = sorted(glob.glob(os.path.join(PX4_ROOT, 'msg', '*.msg')) + glob.glob(os.path.join(PX4_ROOT, 'msg', 'versioned', '*.msg'))) - # stdout must stay clean: several callers print machine-parsed output - subprocess.run([sys.executable, _ZENOH_GENERATOR, '--zenoh-config', - '-f'] + msg_files + ['-o', out_dir, '-e', _ZENOH_TEMPLATES], - check=True, stdout=subprocess.DEVNULL) + # stdout must stay clean: several callers print machine-parsed output. + # Capture rather than discard it, because the generator reports missing + # imports on stdout; discarding left a CalledProcessError whose argv dump + # (every .msg path, ~9kB on one line) buried the actual cause. + result = subprocess.run([sys.executable, _ZENOH_GENERATOR, '--zenoh-config', + '-f'] + msg_files + ['-o', out_dir, '-e', _ZENOH_TEMPLATES], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + if result.returncode != 0: + detail = ((result.stdout or '') + (result.stderr or '')).strip() + sys.exit('loadconfig: {} failed (exit {})\n{}'.format( + os.path.basename(_ZENOH_GENERATOR), result.returncode, + detail or '(no output)')) os.environ['ZENOH_KCONFIG_TOPICS'] = os.path.join(out_dir, 'Kconfig.topics')