diff mbox series

parse/ast: improve error handling for invalid task dependencies

Message ID 20260729142924.67335-1-matt@madison.systems
State Accepted, archived
Commit d1886335f0d7fa86e87c6001d5be306a8e90586b
Headers show
Series parse/ast: improve error handling for invalid task dependencies | expand

Commit Message

Matt Madison July 29, 2026, 2:29 p.m. UTC
The per-recipe providers handling that went int with commit
fb119c7888ae8a749aa824f8c51780176af077f9 throws a ValueError
exception if an entry in a task's [depends] list is malformed.

This results in a traceback of the form:

  ERROR: Unable to parse <recipe-name>
  Traceback (most recent call last):
    File "<top>/bitbake/lib/bb/cooker.py", line 2334, in parse_next
      raise result
  ValueError: not enough values to unpack (expected 2, got 1)

  ERROR: Parsing halted due to errors, see error messages above

which makes it difficult to find the source of the parsing problem,
particularly if the invalid dependency is added in a bbclass that
is shared across many recipes.

Fix this by catching the ValueError and issuing a fatal error
message with more information about the problem.

Signed-off-by: Matt Madison <matt@madison.systems>
---
 lib/bb/parse/ast.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py
index e23ef6db3..a372b3534 100644
--- a/lib/bb/parse/ast.py
+++ b/lib/bb/parse/ast.py
@@ -507,7 +507,10 @@  def handleVirtRecipeProviders(tasklist, d):
         taskdeps = (d.getVarFlag(task, "depends") or "").split()
         remapped = []
         for entry in taskdeps:
-            r, t = entry.split(":")
+            try:
+                r, t = entry.split(":")
+            except ValueError:
+                bb.fatal("Error, incorrect format for task dependency (task '%s'): %s" % (task, entry))
             if r in virtprovs:
                 r = d.getVar("PREFERRED_PROVIDER_" + r)
             remapped.append("%s:%s" % (r, t))