Merge branch 'jill/migrate-to-connect-sdk' into jill/handle-open-ssh-keys

This commit is contained in:
Jill Regan
2026-02-22 12:37:44 -05:00
2 changed files with 17 additions and 16 deletions

View File

@@ -549,7 +549,7 @@ describe("loadSecrets when using Service Account", () => {
describe("secret reference validation", () => { describe("secret reference validation", () => {
it("fails with clear message when a secret reference is invalid", async () => { 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( (Secrets.validateSecretReference as jest.Mock).mockImplementationOnce(
() => { () => {
throw new Error("invalid reference format"); throw new Error("invalid reference format");
@@ -572,7 +572,6 @@ describe("loadSecrets when using Service Account", () => {
} }
}, },
); );
mockResolve.mockResolvedValue("value1");
await expect(loadSecrets(false)).rejects.toThrow( await expect(loadSecrets(false)).rejects.toThrow(
"Invalid secret reference(s): OTHER", "Invalid secret reference(s): OTHER",
@@ -836,21 +835,21 @@ describe("findMatchingFieldAndFile", () => {
describe("findSectionIdsByQuery", () => { describe("findSectionIdsByQuery", () => {
it("throws when sections is empty", () => { it("throws when sections is empty", () => {
expect(() => findSectionIdsByQuery([], "section-1")).toThrow( 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", () => { it("throws when sections is null/undefined", () => {
expect(() => expect(() =>
findSectionIdsByQuery(undefined as unknown as FullItem["sections"], "x"), 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", () => { it("throws when section query matches no section", () => {
const sections = [{ id: "sec-1", label: "Section 1" }]; const sections = [{ id: "sec-1", label: "Other" }];
expect( expect(() =>
findSectionIdsByQuery(sections as FullItem["sections"], "sec-1"), findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"),
).toEqual(["sec-1"]); ).toThrow(/No section matching "nonexistent" found in specified item/);
}); });
it("returns section id when section matches by label", () => { it("returns section id when section matches by label", () => {
@@ -864,7 +863,7 @@ describe("findSectionIdsByQuery", () => {
const sections = [{ id: "sec-1", label: "Other" }]; const sections = [{ id: "sec-1", label: "Other" }];
expect(() => expect(() =>
findSectionIdsByQuery(sections as FullItem["sections"], "nonexistent"), 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", () => { it("returns multiple ids when multiple sections match", () => {

View File

@@ -120,7 +120,6 @@ const getFileContentWithRetry = async (
itemId: string, itemId: string,
fileId: string, fileId: string,
): Promise<string> => { ): Promise<string> => {
const maxAttempts = 3; const maxAttempts = 3;
const retryDelayMs = 2000; const retryDelayMs = 2000;
for (let attempt = 1; attempt <= maxAttempts; attempt++) { for (let attempt = 1; attempt <= maxAttempts; attempt++) {
@@ -301,7 +300,7 @@ export const getEnvVarNamesWithSecretRefs = (): string[] =>
); );
const validateSecretRefs = (envNames: string[]): void => { const validateSecretRefs = (envNames: string[]): void => {
const invalid: string[] = []; const invalid: { name: string; message: string }[] = [];
for (const envName of envNames) { for (const envName of envNames) {
const ref = process.env[envName]; const ref = process.env[envName];
@@ -311,15 +310,18 @@ const validateSecretRefs = (envNames: string[]): void => {
try { try {
Secrets.validateSecretReference(ref); Secrets.validateSecretReference(ref);
} catch { } catch (err) {
invalid.push(envName); const message = err instanceof Error ? err.message : String(err);
invalid.push({ name: envName, message });
} }
} }
// Throw an error if any secret references are invalid // Throw an error if any secret references are invalid
if (invalid.length > 0) { if (invalid.length > 0) {
const names = invalid.join(", "); const details = invalid
throw new Error(`Invalid secret reference(s): ${names}`); .map(({ name, message }) => `${name}: ${message}`)
.join("; ");
throw new Error(`Invalid secret reference(s): ${details}`);
} }
}; };