Bug 16443

Summary: recipetool create: npm: fail when parsing non-compliant licenses defined in package.json
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Romain Naour <romain.naour>
Component: Scripts and ToolsAssignee: Romain Naour <romain.naour>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Medium CC: randy.macleod, ross.burton, yoann.congal
Version: 6.1   
Target Milestone: 6.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
recipetool create: npm: fail when parsing licenses defined in package.json none

Description Romain Naour 2026-10-01 12:56:54 UTC
Created attachment 5249 [details]
recipetool create: npm: fail when parsing licenses defined in package.json

Hello,

recipetool from Wrynose (and likely from master) fail to generate the recipe template (.bb) to package a npm project when licenses defined in package.json are used in last resort (when there is no license file found).
  
      FileNotFoundError: [Errno 2] No such file or directory: '[...]/openembedded-core/meta/files/common-licenses/[foo]'

Since commit [1], the package.json parsing expect a SPDX format while it's not guaranteed [2]. _get_licenses_from_package_json() fail to parse custom license string containing spaces, each space separated text is handled as a license info added to fallback_licenses list. Latter, generate_common_licenses_chksums() uses common license files present in COMMON_LICENSE_DIR. So any listed license in fallback_licenses (fallback_licenses_flat), must exist in COMMON_LICENSE_DIR.

We can still find a few npm package using custom strings:

      "license": "SEE LICENSE IN LICENSE",
      "license": "Apache 2.0"
      "license": "CC BY 4.0"

While such npm package must be fixed upstream, the recipetool should not crash and careful check its input from parsed package.json files.

Since offending npm packages doesn't provide any further licensing information, what should recipetool do?

Here is an experimental patch to filter out non SPDX licences from fallback_licenses_flat.

[1] https://github.com/openembedded/openembedded-core/commit/445604cfc4a5813ea635f18053cd1f673bf0b830
[2] https://docs.npmjs.com/cli/v12/configuring-npm/package-json#license

Best regards,
Romain
Comment 1 Randy MacLeod 2026-10-01 14:46:30 UTC
Should exit more gracefully with a sensible error.