|SUCCESS| dts: ConfigurationError not thrown due to lack of next default value

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Tue Apr 14 22:25:35 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163037

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-04-14

Review of patch: dts: ConfigurationError not thrown due to lack of next default value

git sha: Not available in patch file
Author: Riley Fletcher <rileyf at linux.ibm.com>
Subject: [PATCH] dts: ConfigurationError not thrown due to lack of next default value

This patch fixes the get_port_info() method in the LinuxSession class
to properly handle cases where a PCI address is not found by providing
a default None value to the next() call, allowing a ConfigurationError
to be raised instead of a StopIteration exception.

> diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
> index ee943462c2..3de92b549e 100644
> --- a/dts/framework/testbed_model/linux_session.py
> +++ b/dts/framework/testbed_model/linux_session.py
> @@ -168,7 +168,7 @@ def get_port_info(self, pci_address: str) -> PortInfo:
>              ConfigurationError: If the port could not be found.
>          """
>          bus_info = f"pci@{pci_address}"
> -        port = next(port for port in self._lshw_net_info if port.get("businfo") == bus_info)
> +        port = next((port for port in self._lshw_net_info if port.get("businfo") == bus_info), None)

The fix looks correct. However, does the generator expression need the
extra parentheses? In the corrected line, the generator expression is
wrapped in parentheses:

    next((port for port in ...), None)

While this is syntactically correct, typically next() with a generator
expression would be written as:

    next(iter for iter in collection if condition, default)

The double parentheses (port for port in ...) create a tuple with the
generator as the first element, which is then unpacked by next(). This
works, but is this the intended style for this project?

>          if port is None:
>              raise ConfigurationError(f"Port {pci_address} could not be found on the node.")

The None check and error raising logic is correct and will now properly
execute when the PCI address is not found.


More information about the test-report mailing list