Page MenuHomeSoftware Heritage

npm.client: Handle packages with no versions
ClosedPublic

Authored by anlambert on Apr 11 2019, 3:35 PM.

Details

Summary

Some registered packages may not have any version available, resulting in the following error:

[2019-04-11 12:00:12,754: ERROR/ForkPoolWorker-18] Loading failure, updating to `partial` status
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/swh/loader/core/loader.py", line 894, in load
    self.store_data()
  File "/usr/lib/python3/dist-packages/swh/loader/npm/loader.py", line 294, in store_data
    self._generate_and_load_snapshot()
  File "/usr/lib/python3/dist-packages/swh/loader/npm/loader.py", line 264, in _generate_and_load_snapshot
    latest_version = self.npm_client.latest_package_version()
  File "/usr/lib/python3/dist-packages/swh/loader/npm/client.py", line 59, in latest_package_version
    return self.package_metadata['dist-tags']['latest']
KeyError: 'latest'

So fix and test that specific case.

Related T1644

Diff Detail

Repository
rDLDNPM npm loader
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Apr 11 2019, 3:35 PM
olasd accepted this revision.Apr 11 2019, 4:14 PM
This revision is now accepted and ready to land.Apr 11 2019, 4:14 PM
This revision was landed with ongoing or failed builds.Apr 11 2019, 4:38 PM
This revision was automatically updated to reflect the committed changes.