Skip to content

Commit 5342c4f

Browse files
author
jariy17
committed
fix(eval): let GetEvaluator failures propagate during KMS resolution
Wrapping the failure in InputValidationError mislabelled it: that type sets source: USER, but a GetEvaluator call failing is not the caller's input at fault — it is a service or permissions condition. It also replaced the SDK's error, which already names the operation and the evaluator, with a less precise message. The try/catch is removed so the original error surfaces unchanged.
1 parent 05c4ed5 commit 5342c4f

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/core/eval.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -480,25 +480,17 @@ async function retryWhileRoleUnassumable<T>(send: () => Promise<T>): Promise<T>
480480
// evaluatorKmsKeys collects the customer managed KMS keys of the referenced
481481
// evaluators. The service validates that the execution role can decrypt them when
482482
// the config is created, so a provisioned role has to grant kms:Decrypt on exactly
483-
// these keys. Builtins carry no key, so the common case resolves to nothing. An
484-
// evaluator that cannot be read is fatal: provisioning a role that silently lacks
485-
// Decrypt would fail the create with a far less actionable error.
483+
// these keys. Builtins carry no key, so the common case resolves to nothing. A
484+
// GetEvaluator failure propagates as-is: the SDK's error already names the
485+
// operation and the evaluator, and it is not the caller's input at fault.
486486
async function evaluatorKmsKeys(
487487
evaluatorIds: string[],
488488
control: BedrockAgentCoreControlClient,
489489
): Promise<string[]> {
490490
const keys = await Promise.all(
491491
evaluatorIds.map(async (evaluatorId) => {
492-
try {
493-
const evaluator = await control.send(new GetEvaluatorCommand({ evaluatorId }));
494-
return evaluator.kmsKeyArn;
495-
} catch (error) {
496-
throw new InputValidationError(
497-
`Cannot read evaluator "${evaluatorId}" to determine whether it is encrypted; ` +
498-
`pass --role-arn to supply an execution role instead`,
499-
{ cause: error, meta: { evaluatorId } },
500-
);
501-
}
492+
const evaluator = await control.send(new GetEvaluatorCommand({ evaluatorId }));
493+
return evaluator.kmsKeyArn;
502494
}),
503495
);
504496
return [...new Set(keys.filter((key): key is string => key !== undefined))];

0 commit comments

Comments
 (0)