Guard the honored board_build branch against the empty-list form

voluptuous accepts [] for [cv.string], so vals[-1] could raise an
IndexError at codegen time; an empty list now falls through to the
ignored-option warning.
This commit is contained in:
J. Nick Koston
2026-08-22 13:51:35 -05:00
parent 2dac9112be
commit 2f053371ce
2 changed files with 12 additions and 3 deletions
+8 -3
View File
@@ -595,11 +595,16 @@ async def _add_platformio_options(pio_options: dict[str, str | list[str]]) -> No
# platformio/library.py); filters top-level libraries and
# discovered dependencies
cg.add_platformio_option(key, vals)
elif key in NATIVE_ARDUINO_PIO_OPTIONS and CORE.using_toolchain_arduino:
elif (
key in NATIVE_ARDUINO_PIO_OPTIONS
and CORE.using_toolchain_arduino
and vals
):
# The esp8266 native generator reads these as scalars; the
# schema also permits the list form, where the last value
# wins like a later platformio.ini line. Other native
# toolchains have no equivalent and fall through to the warning.
# wins like a later platformio.ini line (an empty list falls
# through to the ignored-option warning). Other native
# toolchains have no equivalent and fall through too.
cg.add_platformio_option(key, vals[-1])
elif key != "upload_speed":
# upload_speed needs no handling: it is read from the raw