Apply code suggestions
This commit is contained in:
11
src/utils.ts
11
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}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user