Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Throw a meaningful error message when secret reference process fails
Carlos Monastyrski0174d361363e
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.tsindex bb24c9d786..4d83652761 100644--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts@@ -1105,9 +1105,9 @@ export const secretV2BridgeServiceFactory = ({if (shouldExpandSecretReferences) {const secretsGroupByPath = groupBy(decryptedSecrets, (i) => i.secretPath);- await Promise.all(+ const settledPromises = await Promise.allSettled(Object.keys(secretsGroupByPath).map((groupedPath) =>- Promise.all(+ Promise.allSettled(secretsGroupByPath[groupedPath].map(async (decryptedSecret, index) => {const expandedSecretValue = await expandSecretReferences({value: decryptedSecret.secretValue,@@ -1121,6 +1121,34 @@ export const secretV2BridgeServiceFactory = ({)));+ const errors: { path: string; error: string }[] = [];++ settledPromises.forEach((outerResult: PromiseSettledResult<PromiseSettledResult<void>[]>, outerIndex) => {+ const groupedPath = Object.keys(secretsGroupByPath)[outerIndex];++ if (outerResult.status === "rejected") {+ errors.push({+ path: groupedPath,+ error: `Failed to process secret group: ${outerResult.reason}`+ });+ } else {+ // Check inner promise results+ outerResult.value.forEach((innerResult: PromiseSettledResult<void>) => {+ if (innerResult.status === "rejected") {+ errors.push({+ path: groupedPath,+ error: `Failed to expand secret reference: ${innerResult.reason}`+ });+ }+ });+ }+ });+ if (errors.length > 0) {+ throw new ForbiddenRequestError({+ message: "Failed to expand one or more secret references",+ details: errors.map((err) => err.error)+ });+ }}if (!includeImports) {