Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(error): enhance AWS error handling to check for null and object type

Victor Hugo dos Santose37fa0f48c23
diff --git a/backend/src/lib/aws/error.ts b/backend/src/lib/aws/error.ts
index c0e3744ba5..fd267fc9c9 100644
--- a/backend/src/lib/aws/error.ts
+++ b/backend/src/lib/aws/error.ts
@@ -1,4 +1,5 @@
// AWS SDK v3 exception classes are only generated for errors explicitly modeled in a service's API definition.
// Generic errors like ThrottlingException are not modeled by all services (e.g. Secrets Manager, KMS),
// so they cannot be caught with instanceof. This utility checks the error name directly as a fallback.
-export const isAwsError = (error: unknown, name: string): boolean => (error as { name: string }).name === name;
+export const isAwsError = (error: unknown, name: string): boolean =>
+ typeof error === "object" && error !== null && "name" in error && (error as { name: string }).name === name;