mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 13:28:27 +00:00
Throw a meaningful error message when secret reference process fails
This commit is contained in:
@@ -1105,9 +1105,9 @@ export const secretV2BridgeServiceFactory = ({
|
|||||||
|
|
||||||
if (shouldExpandSecretReferences) {
|
if (shouldExpandSecretReferences) {
|
||||||
const secretsGroupByPath = groupBy(decryptedSecrets, (i) => i.secretPath);
|
const secretsGroupByPath = groupBy(decryptedSecrets, (i) => i.secretPath);
|
||||||
await Promise.all(
|
const settledPromises = await Promise.allSettled(
|
||||||
Object.keys(secretsGroupByPath).map((groupedPath) =>
|
Object.keys(secretsGroupByPath).map((groupedPath) =>
|
||||||
Promise.all(
|
Promise.allSettled(
|
||||||
secretsGroupByPath[groupedPath].map(async (decryptedSecret, index) => {
|
secretsGroupByPath[groupedPath].map(async (decryptedSecret, index) => {
|
||||||
const expandedSecretValue = await expandSecretReferences({
|
const expandedSecretValue = await expandSecretReferences({
|
||||||
value: decryptedSecret.secretValue,
|
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) {
|
if (!includeImports) {
|
||||||
|
|||||||
Reference in New Issue
Block a user