#19402·esphome

Device Builder incorrectly marks successful ESPHome compile as failed when handled WARNING contains ModuleNotFoundError

Author: shortblokeCreated Sep 18, 2026Updated Sep 18, 2026

The problem

ESPHome Device Builder 1.14.9 incorrectly marks a successful ESPHome compile as failed when ESPHome emits a non-fatal WARNING containing the text ModuleNotFoundError. This prevents the subsequent OTA upload from running even though ESPHome successfully creates the firmware and exits with code 0.

This appears to be a new variant of #918/ #972. It is also being seen with the PedroKTFC/esphome-tesla-ble project and is reported there as: PedroKTFC/esphome-tesla-ble#393

During compilation ESPHome emits the following warning from nanopb:

WARNING PIO extra-script /data/pio_components/idf/f6f34eba/nanopb/Nanopb/generator/platformio_generator.py (in Nanopb) raised ModuleNotFoundError("No module named 'SCons'"); ignoring its output

ESPHome explicitly treats this as a warning and ignores the extra-script output. The build then completes normally:

INFO Creating factory.bin...
INFO Created: /data/build/tesla-ble/build/firmware.factory.bin
INFO Created: /data/build/tesla-ble/build/firmware.ota.bin
INFO Created: /data/build/tesla-ble/build/firmware.elf
INFO Successfully compiled program.

However, Device Builder reports:

Process exited 0 but output contains errors
Job ... failed (exit code 0)

The UI consequently displays the following and OTA upload is not attempted:

INFO Successfully compiled program.
Compilation failed.

I traced this through Device Builder 1.14.9. controllers/firmware/runner.py checks every output line against _ERROR_PATTERNS:

def _check_error(text: str) -> None:
    ...
    for pattern in _ERROR_PATTERNS:
        if pattern in text:
            has_error_in_output = True
            return

and subsequently determines success using: success = exit_code == 0 and not has_error_in_output, with the _ERROR_PATTERNS in 1.14.9 being:

ModuleNotFoundError
ImportError
FileNotFoundError
command not found

Therefore the handled ESPHome warning: WARNING ... raised ModuleNotFoundError("No module named 'SCons'"); ignoring its output, sets has_error_in_output = True. The ESPHome process subsequently exits successfully with code 0, but Device Builder nevertheless marks the compile job failed.

Verification

Running the same configuration directly with the ESPHome CLI succeeds: CMAKE_BUILD_PARALLEL_LEVEL=1 esphome compile /config/esphome/tessy.yaml

Result:

INFO Successfully compiled program.
ESPHOME EXIT CODE: 0

Running: CMAKE_BUILD_PARALLEL_LEVEL=1 esphome run /config/esphome/tessy.yaml also successfully performs the OTA update:

INFO OTA successful
INFO Successfully uploaded program.

The ESP32-C6 subsequently boots ESPHome 2026.9.0 and operates normally.

Which version of ESPHome has the issue?

ESPHome: 2026.9.0, ESPHome Device Builder: 1.14.9, ESP-IDF: 5.5.5

What type of installation are you using?

Home Assistant Add-on

What platform are you using?

ESP32

Component causing the issue

tesla-ble

YAML Config

yaml

Anything in the logs that might be useful for us?

txt

Additional information

Relation to PRs #918/ #972

This appears closely related to #918and its fix in #972. That issue involved harmless nanopb output containing No module named ... being interpreted by Device Builder as a build failure. PR #972 removed the broad No module named detection while retaining ModuleNotFoundError as an error pattern. ESPHome 2026.9.0 now provides a case where ModuleNotFoundError itself can legitimately occur inside a handled warning:

WARNING ... raised ModuleNotFoundError("No module named 'SCons'"); ignoring its output

Consequently the remaining ModuleNotFoundError matcher can still produce the same type of false positive.

Expected behaviour

If ESPHome handles an exception internally, reports it as a WARNING, successfully creates the firmware and exits with status 0, Device Builder should not change the compile job to failed solely because the warning text contains ModuleNotFoundError.

The successful compile should allow the dependent OTA upload to proceed.

Actual behaviour

Device Builder detects the literal ModuleNotFoundError substring, marks the exit-code-0 compile as failed, displays Compilation failed, and does not perform the OTA upload.

Possible fix

I'm not sure whats possible here, error detection may need to distinguish an actual unhandled Python exception/traceback from an ESPHome warning describing an exception that ESPHome has already handled. For example, a line explicitly logged by ESPHome as: WARNING ... raised ModuleNotFoundError(...); ignoring its output should presumably not override a successful process exit code.

Alternatively, the output scanning could look for traceback context rather than treating every occurrence of ModuleNotFoundError as fatal.

Related issues

  • esphome/device-builder#918
  • esphome/device-builder#972
  • PedroKTFC/esphome-tesla-ble#393