Skip to content

Commit

Permalink
fix: properly report errors when lock file cannot be parsed
Browse files Browse the repository at this point in the history
The function returns only 4 arguments upon errors, but 5 are expected
and returned when everything succeeded.
  • Loading branch information
devversion committed Nov 15, 2024
1 parent bfddcb3 commit 8d2043a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions npm/private/pnpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ def _parse_lockfile(parsed, err):
A tuple of (importers dict, packages dict, patched_dependencies dict, error string)
"""
if err != None or parsed == None or parsed == {}:
return {}, {}, {}, err
return {}, {}, {}, -1, err if err != None else "could not parse Yaml config"

if not types.is_dict(parsed):
return {}, {}, {}, "lockfile should be a starlark dict"
return {}, {}, {}, -1, "lockfile should be a starlark dict"
if not parsed.get("lockfileVersion", False):
return {}, {}, {}, "expected lockfileVersion key in lockfile"
return {}, {}, {}, -1, "expected lockfileVersion key in lockfile"

# Lockfile version may be a float such as 5.4 or a string such as '6.0'
lockfile_version = str(parsed["lockfileVersion"])
Expand Down

0 comments on commit 8d2043a

Please sign in to comment.