Skip to content

Commit 7d5af4b

Browse files
committed
fix: properly report errors when lock file cannot be parsed
The function returns only 4 arguments upon errors, but 5 are expected and returned when everything succeeded.
1 parent bfddcb3 commit 7d5af4b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

npm/private/pnpm.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ def _parse_lockfile(parsed, err):
531531
A tuple of (importers dict, packages dict, patched_dependencies dict, error string)
532532
"""
533533
if err != None or parsed == None or parsed == {}:
534-
return {}, {}, {}, err
534+
return {}, {}, {}, -1, err if err != None else "could not parse Yaml config"
535535

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

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

0 commit comments

Comments
 (0)