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.
This commit is contained in:
AC 2025-04-06 17:03:53 +08:00
parent 04cbadb197
commit 4093e4c500

View File

@ -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,