Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly report errors when lock file cannot be parsed #2020

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading