From 4093e4c50062ae6992f7d5170b3487067ac39e9c Mon Sep 17 00:00:00 2001 From: AC Date: Sun, 6 Apr 2025 17:03:53 +0800 Subject: [PATCH] Improve AWS Bedrock Configuration Error Handling - Enhanced error messages in `getAwsCredentials` to provide clearer feedback when AWS Bedrock is not configured properly. - Added checks for missing Bedrock Access Key ID and Secret Access Key, with specific error messages for each case. --- app/api/bedrock/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/api/bedrock/index.ts b/app/api/bedrock/index.ts index c568c886f..4f8320400 100644 --- a/app/api/bedrock/index.ts +++ b/app/api/bedrock/index.ts @@ -15,7 +15,15 @@ const ALLOWED_PATH = new Set([BedrockConfig.ChatPath]); function getAwsCredentials() { const config = getServerSideConfig(); if (!config.isBedrock) { - throw new Error("AWS Bedrock is not configured properly"); + throw new Error( + "AWS Bedrock is not configured properly (ENABLE_AWS_BEDROCK is not true)", + ); + } + if (!config.bedrockAccessKeyId) { + throw new Error("AWS Bedrock Access Key ID is missing or empty."); + } + if (!config.bedrockSecretAccessKey) { + throw new Error("AWS Bedrock Secret Access Key is missing or empty."); } return { accessKeyId: config.bedrockAccessKeyId as string,