{"record":{"id":"85be689fe6013712","repo":"Graphify-Labs/graphify","slug":"bedrock-api-error-code-msg","errorCode":null,"errorMessage":"Bedrock API error ({code}): {msg}","messagePattern":"Bedrock API error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"graphify/llm.py","lineNumber":1717,"sourceCode":"        \"bedrock-runtime\",\n        config=botocore.config.Config(\n            read_timeout=_resolve_api_timeout(),\n            connect_timeout=10,\n            retries={\"max_attempts\": _resolve_max_retries() + 1, \"mode\": \"adaptive\"},\n        ),\n    )\n\n    try:\n        resp = client.converse(\n            modelId=model,\n            system=[{\"text\": _extraction_system(deep=deep_mode)}],\n            messages=[{\"role\": \"user\", \"content\": _bedrock_content(user_message, images or [])}],\n            inferenceConfig=_bedrock_inference_config(max_tokens, model),\n        )\n    except botocore.exceptions.ClientError as exc:\n        code = exc.response[\"Error\"][\"Code\"]\n        msg = exc.response[\"Error\"][\"Message\"]\n        raise RuntimeError(f\"Bedrock API error ({code}): {msg}\") from exc\n\n    text = _bedrock_response_text(resp, default=\"{}\")\n    result = _parse_llm_json(text)\n    usage = resp.get(\"usage\", {})\n    result[\"input_tokens\"] = usage.get(\"inputTokens\", 0)\n    result[\"output_tokens\"] = usage.get(\"outputTokens\", 0)\n    result[\"model\"] = model\n    result[\"finish_reason\"] = \"length\" if resp.get(\"stopReason\") == \"max_tokens\" else \"stop\"\n    if _response_is_hollow(text, result) and result[\"finish_reason\"] != \"length\":\n        print(\n            \"[graphify] bedrock returned a hollow response; treating as \"\n            \"truncation so adaptive retry can bisect the chunk.\",\n            file=sys.stderr,\n        )\n        result[\"finish_reason\"] = \"length\"\n    return result\n\n","sourceCodeStart":1699,"sourceCodeEnd":1735,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/llm.py#L1699-L1735","documentation":"Raised when boto3's `client.converse(...)` raises `botocore.exceptions.ClientError`. The message surfaces the AWS error Code and Message (e.g. AccessDeniedException, ValidationException, ThrottlingException, ModelStreamErrorException, ModelNotReadyException). These are service-side rejections of the request: credentials lack bedrock:InvokeModel, the modelId is wrong for the region, the model isn't subscribed/ready, or throughput was throttled.","triggerScenarios":"Bedrock Converse calls with (1) an IAM principal missing bedrock:InvokeModel on the model, (2) a modelId not available/subscribed in AWS_REGION (default us-east-1), (3) throttling/overload on on-demand throughput, (4) invalid inference configuration for that model.","commonSituations":"Forgot to request model access in the Bedrock console; cross-region default (env vars unset so us-east-1 is used but the model lives elsewhere); IAM policy scoped to the wrong ARN; burst traffic on small on-demand quotas during bulk extraction.","solutions":["Read the (code) in the message: AccessDeniedException → grant bedrock:InvokeModel; ValidationException → fix modelId/inferenceConfig; ThrottlingException → back off and retry with fewer parallel requests.","Verify model access is enabled for the exact model in the exact region (set AWS_REGION/AWS_DEFAULT_REGION accordingly).","Confirm the modelId string matches Bedrock's naming (e.g. anthropic.claude-3-5-sonnet-...:0 or inference-profile ARNs for cross-region).","For throttling, lower concurrency and add retry/backoff around extraction calls."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import time\nRETRYABLE = {\"ThrottlingException\", \"ServiceUnavailableException\", \"ModelStreamErrorException\"}\nfor attempt in range(4):\n    try:\n        result = extract_files_direct(chunk, root, backend=\"bedrock\")\n        break\n    except RuntimeError as e:\n        code = e.args[0].split(\"(\")[1].split(\")\")[0] if \"(\" in e.args[0] else \"\"\n        if code not in RETRYABLE or attempt == 3:\n            raise  # AccessDenied / Validation are config bugs — fix, don't retry\n        time.sleep(2 ** attempt)","preventionTips":["Grant bedrock:InvokeModel on the exact model ARN to the executing role before running extraction.","Request/verify model access in the target region; keep AWS_REGION and modelId consistent (mind inference-profile ARNs for cross-region).","Retry only throttling-class codes; config errors (AccessDenied, Validation) must be fixed."],"tags":["bedrock","aws","iam","api-error","throttling"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}