Skip to contentSkip to conversation

license: fix list_licenses() crash on CLOSED and empty licenses

PATCH In review Dmitry Baryshkov 2 participants 2 messages Jul 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 license: fix list_licenses() crash on CLOSED and empty licenses

oe.license.list_licenses() passes the result of parse_legacy_license() straight into walk_license(), which unconditionally iterates node.children. For LICENSE = "CLOSED" (and for an empty license string) parse_legacy_license() returns None, so walk_license(None) dereferences None.children and aborts do_package_qa with:

AttributeError: 'NoneType' object has no attribute 'children'

This breaks packaging for every CLOSED-licensed recipe reaching the obsolete-license QA check.

Guard the walk against a None node, mirroring the existing "if node:" check in the neighbouring apply_pkg_license_exclusion().

Fixes e9d424738d6f ("classes/conf/lib: Parse LICENSE as SPDX Expression")
Assisted-by Claude:claude-opus-4-8
---
 meta/lib/oe/license.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oe/license.py +3 -1
index a1dce143dd20..adcfc827cfc0 100644
@@ -235,7 +235,9 @@ def list_licenses(licensestr, d):
         for child in node.children:
             walk_license(child)
 
-    walk_license(parse_legacy_license(d, licensestr))
+    node = parse_legacy_license(d, licensestr)
+    if node:
+        walk_license(node)
     return set(licenses)
 
 def return_spdx(d, license):
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dmitry Baryshkov via lists.openembedded.org

oe.license.list_licenses() passes the result of parse_legacy_license() straight into walk_license(), which unconditionally iterates node.children. For LICENSE = "CLOSED" (and for an empty license string) parse_legacy_license() returns None, so walk_license(None) dereferences None.children and aborts do_package_qa with:

Quoted 8 lines

AttributeError: 'NoneType' object has no attribute 'children'

This breaks packaging for every CLOSED-licensed recipe reaching the obsolete-license QA check.

Guard the walk against a None node, mirroring the existing "if node:" check in the neighbouring apply_pkg_license_exclusion().

LGTM, thanks.

Quoted 38 lines
Fixes e9d424738d6f ("classes/conf/lib: Parse LICENSE as SPDX Expression")
Assisted-by Claude:claude-opus-4-8
---
 meta/lib/oe/license.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/oe/license.py +3 -2
index a1dce143dd20..adcfc827cfc0 100644
@@ -235,7 +235,9 @@ def list_licenses(licensestr, d):
         for child in node.children:
             walk_license(child)
 
-    walk_license(parse_legacy_license(d, licensestr))
+    node = parse_legacy_license(d, licensestr)
+    if node:
+        walk_license(node)
     return set(licenses)
 
 def return_spdx(d, license):
--

2.47.3

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#241552):
https://lists.openembedded.org/g/openembedded-core/message/241552
Mute This Topic: https://lists.openembedded.org/mt/120378577/3616693
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-