From 8d2043a46fc9d8b5abd0fbd7468a4088fdadc708 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 15 Nov 2024 16:11:16 +0000 Subject: [PATCH] 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. --- npm/private/pnpm.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/npm/private/pnpm.bzl b/npm/private/pnpm.bzl index 398643ec0..a6343d230 100644 --- a/npm/private/pnpm.bzl +++ b/npm/private/pnpm.bzl @@ -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"])