From dc90451a94226792d67567dd0243df96debe84e1 Mon Sep 17 00:00:00 2001 From: Jill Regan Date: Sun, 22 Feb 2026 12:31:37 -0500 Subject: [PATCH 1/2] Apply code suggestions --- src/utils.test.ts | 3 +-- src/utils.ts | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils.test.ts b/src/utils.test.ts index 575c30f..a74874f 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -356,7 +356,7 @@ describe("loadSecrets when using Service Account", () => { describe("secret reference validation", () => { it("fails with clear message when a secret reference is invalid", async () => { - process.env.MY_SECRET = "op://invalid/ref/form"; + process.env.MY_SECRET = "op://x"; (Secrets.validateSecretReference as jest.Mock).mockImplementationOnce( () => { throw new Error("invalid reference format"); @@ -379,7 +379,6 @@ describe("loadSecrets when using Service Account", () => { } }, ); - mockResolve.mockResolvedValue("value1"); await expect(loadSecrets(false)).rejects.toThrow( "Invalid secret reference(s): OTHER", diff --git a/src/utils.ts b/src/utils.ts index e66cc18..6a3e0bb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -38,7 +38,7 @@ const getEnvVarNamesWithSecretRefs = (): string[] => ); const validateSecretRefs = (envNames: string[]): void => { - const invalid: string[] = []; + const invalid: { name: string; message: string }[] = []; for (const envName of envNames) { const ref = process.env[envName]; @@ -48,15 +48,16 @@ const validateSecretRefs = (envNames: string[]): void => { try { Secrets.validateSecretReference(ref); - } catch { - invalid.push(envName); + } catch (err) { + const message = err instanceof Error ? err.message : String(err); + invalid.push({ name: envName, message }); } } // Throw an error if any secret references are invalid if (invalid.length > 0) { - const names = invalid.join(", "); - throw new Error(`Invalid secret reference(s): ${names}`); + const details = invalid.map(({ name, message }) => `${name}: ${message}`).join("; "); + throw new Error(`Invalid secret reference(s): ${details}`); } }; From 44af64418a66562e6c4e4cd02e80e6f96f90376a Mon Sep 17 00:00:00 2001 From: Jill Regan Date: Sun, 22 Feb 2026 12:37:21 -0500 Subject: [PATCH 2/2] Update unit test --- src/utils.test.ts | 16 ++++++++-------- src/utils.ts | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/utils.test.ts b/src/utils.test.ts index 576ae9c..e3f03ef 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -835,21 +835,21 @@ describe("findMatchingFieldAndFile", () => { describe("findSectionIdsByQuery", () => { it("throws when sections is empty", () => { expect(() => findSectionIdsByQuery([], "section-1")).toThrow( - /section section-1 could not be found/, + /Item has no sections; cannot resolve section "section-1"/, ); }); it("throws when sections is null/undefined", () => { expect(() => findSectionIdsByQuery(undefined as unknown as FullItem["sections"], "x"), - ).toThrow(/could not be found/); + ).toThrow(/Item has no sections; cannot resolve section "x"/); }); - it("returns section id when section matches by id", () => { - const sections = [{ id: "sec-1", label: "Section 1" }]; - expect( - findSectionIdsByQuery(sections as FullItem["sections"], "sec-1"), - ).toEqual(["sec-1"]); + it("throws when section query matches no section", () => { + const sections = [{ id: "sec-1", label: "Other" }]; + expect(() => + findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"), + ).toThrow(/No section matching "nonexistent" found in specified item/); }); it("returns section id when section matches by label", () => { @@ -863,7 +863,7 @@ describe("findSectionIdsByQuery", () => { const sections = [{ id: "sec-1", label: "Other" }]; expect(() => findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"), - ).toThrow(/could not be found/); + ).toThrow(/No section matching "nonexistent" found in specified item/); }); it("returns multiple ids when multiple sections match", () => { diff --git a/src/utils.ts b/src/utils.ts index 3534833..d1f1752 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -113,7 +113,6 @@ const getFileContentWithRetry = async ( itemId: string, fileId: string, ): Promise => { - const maxAttempts = 3; const retryDelayMs = 2000; for (let attempt = 1; attempt <= maxAttempts; attempt++) { @@ -299,7 +298,9 @@ const validateSecretRefs = (envNames: string[]): void => { // Throw an error if any secret references are invalid if (invalid.length > 0) { - const details = invalid.map(({ name, message }) => `${name}: ${message}`).join("; "); + const details = invalid + .map(({ name, message }) => `${name}: ${message}`) + .join("; "); throw new Error(`Invalid secret reference(s): ${details}`); } };