From 2982d75fd22e52f7a383b7455dc45503b497bd88 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 23 Aug 2026 14:04:42 -0500 Subject: [PATCH] Warn when the summary is skipped, name the file and row, pin the blanket test on output The blanket backstop and the zero-partition skip log at warning naming their input, so a regression or broken table is visible where the missing line is observed, with the traceback at debug. The blank-cell ValueError carries the partition and csv path, and the blanket test asserts no half-formed bar prints instead of a vacuous Traceback check. --- esphome/espidf/size_summary.py | 19 +++++++++++++++---- tests/unit_tests/test_size_summary.py | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/esphome/espidf/size_summary.py b/esphome/espidf/size_summary.py index 60b17f6ebc..40dbedbfe3 100644 --- a/esphome/espidf/size_summary.py +++ b/esphome/espidf/size_summary.py @@ -63,7 +63,12 @@ def _find_app_partition_size(partitions_csv: Path) -> int: continue ptype, psubtype, psize = cells[1], cells[2], cells[4] if ptype in ("app", "0") and psubtype in ("factory", "ota_0"): - return _parse_size(psize) + try: + return _parse_size(psize) + except ValueError as err: + raise ValueError( + f"{err} for partition {cells[0]} in {partitions_csv}" + ) from err raise ValueError(f"No app+factory or app+ota_0 partition in {partitions_csv}") @@ -84,8 +89,10 @@ def print_summary(size_json: Path, partitions_csv: Path | None) -> None: try: _print_summary(size_json, partitions_csv) except Exception as e: # noqa: BLE001 # pylint: disable=broad-exception-caught - # Backstop for shapes the named guards below miss - _LOGGER.debug("Skipping size summary: %s", e) + # Backstop for shapes the named guards below miss; warning so a + # regression here cannot go missing indefinitely + _LOGGER.warning("Skipping size summary for %s: %s", size_json, e) + _LOGGER.debug("Size summary failure detail", exc_info=True) def _print_summary(size_json: Path, partitions_csv: Path | None) -> None: @@ -120,6 +127,10 @@ def _print_summary(size_json: Path, partitions_csv: Path | None) -> None: return if app_size <= 0: # Skipping also fails CI's Flash extraction, the right outcome here - _LOGGER.debug("Skipping Flash summary: app partition size is 0") + _LOGGER.warning( + "Skipping Flash summary: app partition size is %s in %s", + app_size, + partitions_csv, + ) return print(f"Flash: {_format_bar(image_size, app_size)}") diff --git a/tests/unit_tests/test_size_summary.py b/tests/unit_tests/test_size_summary.py index 3ca476018c..f32401db02 100644 --- a/tests/unit_tests/test_size_summary.py +++ b/tests/unit_tests/test_size_summary.py @@ -206,7 +206,8 @@ def test_print_summary_nested_bad_shapes_never_raise( """The blanket guard keeps unexpected nested shapes from raising.""" size_json = _write_size_json(tmp_path, payload) print_summary(size_json, None) - assert "Traceback" not in capsys.readouterr().err + # No half-formed bar for CI to scrape; every payload fails before printing + assert capsys.readouterr().out == "" def test_print_summary_blank_size_cell_names_the_row(