continuedev/continue · error · Error
AWS Bedrock rerank error (${(error as any).code}): ${error.m
Error message
AWS Bedrock rerank error (${(error as any).code}): ${error.message} What it means
Thrown by BedrockReranker.rerank when the AWS SDK rejects the rerank request and the error carries an AWS-specific `code` field (e.g. AccessDeniedException, ThrottlingException, ValidationException). The SDK error code and message are wrapped into a plain Error with the 'AWS Bedrock rerank error' prefix. It always indicates a failed InvokeModel call to a rerank model such as amazon.rerank-v1.
Source
Thrown at core/llm/llms/Bedrock.ts:737
const decoder = new TextDecoder();
const decoded = decoder.decode(response.body);
try {
const responseBody = JSON.parse(decoded);
// Sort results by index to maintain original order
return responseBody.results
.sort((a: any, b: any) => a.index - b.index)
.map((result: any) => result.relevance_score);
} catch (e) {
throw new Error(
`Error parsing JSON from Bedrock response body:\n${decoded}, ${JSON.stringify(e)}`,
);
}
} catch (error: unknown) {
if (error instanceof Error) {
if ("code" in error) {
// AWS SDK specific errors
throw new Error(
`AWS Bedrock rerank error (${(error as any).code}): ${error.message}`,
);
}
throw new Error(`Error in BedrockReranker.rerank: ${error.message}`);
}
throw new Error(
"Error in BedrockReranker.rerank: Unknown error occurred",
);
}
}
}
export default Bedrock;
View on GitHub (pinned to 5522c6f44c)
Solutions
- Check the (code) portion: AccessDeniedException -> fix IAM/credentials; ThrottlingException -> retry with backoff or request quota increase; ValidationException -> check numberOfResults/query size
- Verify the rerank model ID (e.g. amazon.rerank-v1) is available and enabled in your configured AWS region
- Confirm AWS credentials (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY) and region are set and have bedrock:InvokeModel permission
- Wrap rerank() calls in retry-with-exponential-backoff for transient ThrottlingException codes
Example fix
// before
const results = await bedrockReranker.rerank(query, chunks);
// after
const results = await withRetry(
() => bedrockReranker.rerank(query, chunks),
{ retries: 3, onRetry: (e) => !/Throttling|TooMany/.test(e.message) }
); Defensive patterns
Strategy: retry
Type guard
function isAwsCodedError(e: unknown): e is Error & { code: string } {
return e instanceof Error && 'code' in e;
} Try / catch
try {
const scores = await reranker.rerank(query, chunks);
} catch (e) {
if (e instanceof Error && /AWS Bedrock rerank error \((Throttling|TooManyRequests)/.test(e.message)) {
await backoff(); // retry
} else throw e;
} Prevention
- Pre-validate IAM bedrock:InvokeModel permission with a dry-run call
- Cache rerank results keyed by (query, chunk hashes) to reduce call volume
- Use exponential backoff for ThrottlingException codes
When it happens
Trigger: Calling rerank() with an invalid AWS key/secret (AccessDeniedException / UnrecognizedClientException), a model the account has no access to, a malformed rerank request payload (ValidationException), missing aws region config, or hitting Bedrock throttling limits (TooManyRequestsException / ThrottlingException).
Common situations: Wrong or expired AWS credentials in env, IAM user without bedrock:InvokeModel permission, using a rerank model not enabled in the given region, exceeding TPS quotas, or a modelId typo.
Related errors
- Error in BedrockReranker.rerank: ${error.message}
- Error in BedrockReranker.rerank: Unknown error occurred
- AWS Bedrock rerank error (${(error as any).code}): ${error.m
- AWS profile with name ${profile} not found in ~/.aws/credent
- Malformed JSON received from Bedrock: ${decoded}
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/6b6f3f1c89270f8e.
Report an issue: GitHub.