openSUSE / obs-service-node_modules

MIT License
7 stars 11 forks source link

Errors when dependencies specify multiple integrity values #34

Closed marcosbc closed 1 year ago

marcosbc commented 1 year ago

We are seeing an issue when a package-lock.json specifies dependencies with multiple integrity values:

Files could not be expanded: service error: ValueError: too many values to unpack (expected 2)

service node_modules failed:
time="2023-09-18T16:21:19+02:00" level=warning msg="Path \"/etc/SUSEConnect\" from \"/etc/containers/mounts.conf\" doesn't exist, skipping"
time="2023-09-18T16:21:19+02:00" level=warning msg="Path \"/etc/zypp/credentials.d/SCCcredentials\" from \"/etc/containers/mounts.conf\" doesn't exist, skipping"
Running /usr/lib/obs/service//node_modules --cpio node_modules.obscpio --output node_modules.spec.inc --source-offset 10000 --outdir /var/cache/obs/VJvo7VsTt4d9/out
Traceback (most recent call last):
File "/usr/lib/obs/service//node_modules", line 624, in
sys.exit(main(args))
File "/usr/lib/obs/service//node_modules", line 376, in main
process_packagelock_file(js)
File "/usr/lib/obs/service//node_modules", line 341, in process_packagelock_file
collect_v3_deps(js["packages"])
File "/usr/lib/obs/service//node_modules", line 326, in collect_v3_deps
add_standard_dependency(parse_supported_fetch_url(url), integrity, module, path)
File "/usr/lib/obs/service//node_modules", line 230, in add_standard_dependency
algo, chksum = integrity.split("-", 2)
ValueError: too many values to unpack (expected 2)

Here you have an example of a problematic case:

    "node_modules/array-unique": {
      "version": "0.3.2",
      "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
      "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==",
      "dev": true,
      "engines": {
        "node": ">=0.10.0"
      }
    },

As you can see, the integrity field contains the following values, which is causing the OBS service to fail: