{"record":{"id":"6b6f3f1c89270f8e","repo":"continuedev/continue","slug":"aws-bedrock-rerank-error-error-as-any-code","errorCode":null,"errorMessage":"AWS Bedrock rerank error (${(error as any).code}): ${error.message}","messagePattern":"AWS Bedrock rerank error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Bedrock.ts","lineNumber":737,"sourceCode":"\n      const decoder = new TextDecoder();\n      const decoded = decoder.decode(response.body);\n      try {\n        const responseBody = JSON.parse(decoded);\n        // Sort results by index to maintain original order\n        return responseBody.results\n          .sort((a: any, b: any) => a.index - b.index)\n          .map((result: any) => result.relevance_score);\n      } catch (e) {\n        throw new Error(\n          `Error parsing JSON from Bedrock response body:\\n${decoded}, ${JSON.stringify(e)}`,\n        );\n      }\n    } catch (error: unknown) {\n      if (error instanceof Error) {\n        if (\"code\" in error) {\n          // AWS SDK specific errors\n          throw new Error(\n            `AWS Bedrock rerank error (${(error as any).code}): ${error.message}`,\n          );\n        }\n        throw new Error(`Error in BedrockReranker.rerank: ${error.message}`);\n      }\n      throw new Error(\n        \"Error in BedrockReranker.rerank: Unknown error occurred\",\n      );\n    }\n  }\n}\n\nexport default Bedrock;\n","sourceCodeStart":719,"sourceCodeEnd":751,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Bedrock.ts#L719-L751","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nconst results = await bedrockReranker.rerank(query, chunks);\n// after\nconst results = await withRetry(\n  () => bedrockReranker.rerank(query, chunks),\n  { retries: 3, onRetry: (e) => !/Throttling|TooMany/.test(e.message) }\n);","handlingStrategy":"retry","validationCode":null,"typeGuard":"function isAwsCodedError(e: unknown): e is Error & { code: string } {\n  return e instanceof Error && 'code' in e;\n}","tryCatchPattern":"try {\n  const scores = await reranker.rerank(query, chunks);\n} catch (e) {\n  if (e instanceof Error && /AWS Bedrock rerank error \\((Throttling|TooManyRequests)/.test(e.message)) {\n    await backoff(); // retry\n  } else throw e;\n}","preventionTips":["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"],"tags":["aws","bedrock","rerank","iam","throttling"],"backgroundTag":"aws-sdk-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}