{"record":{"id":"9dc3a028c23d9f3d","repo":"windmill-labs/windmill","slug":"service-error-details","errorCode":null,"errorMessage":"Service error: {} (details: {:?})","messagePattern":"Service error: (.+?) \\(details: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-ai/src/ai_bedrock.rs","lineNumber":308,"sourceCode":"        &self.client\n    }\n}\n\n// ============================================================================\n// Error Formatting\n// ============================================================================\n\n/// Format AWS SDK errors with detailed information\npub fn format_bedrock_error<E, R>(error: &aws_sdk_bedrockruntime::error::SdkError<E, R>) -> String\nwhere\n    E: std::fmt::Debug + std::fmt::Display,\n    R: std::fmt::Debug,\n{\n    use aws_sdk_bedrockruntime::error::SdkError;\n\n    match error {\n        SdkError::ServiceError(err) => {\n            format!(\"Service error: {} (details: {:?})\", err.err(), err)\n        }\n        SdkError::ConstructionFailure(err) => {\n            format!(\"Request construction failed: {:?}\", err)\n        }\n        SdkError::DispatchFailure(err) => {\n            format!(\"Request dispatch failed: {:?}\", err)\n        }\n        SdkError::ResponseError(err) => {\n            format!(\"Response error: {:?}\", err)\n        }\n        SdkError::TimeoutError(err) => {\n            format!(\"Request timeout: {:?}\", err)\n        }\n        _ => format!(\"{:?}\", error),\n    }\n}\n\n// ============================================================================","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-ai/src/ai_bedrock.rs#L290-L326","documentation":"When the AWS Bedrock Runtime SDK returns a service-side error, Windmill formats it via format_bedrock_error into \"Service error: {} (details: {:?})\" before surfacing it as an AI job error. The message carries the SdkError's inner error and full debug dump (request id, metadata).","triggerScenarios":"An SdkError::ServiceError from a bedrockruntime invoke/converse call: invalid model ID, throttling, access denied, malformed request body, model not available in region, or context length exceeded.","commonSituations":"Wrong modelId string in AI provider config; AWS credentials/IAM policy lacking bedrock:InvokeModel; model not enabled in the AWS region; exceeding input token limits.","solutions":["Read err.err() in the message to see the AWS error type and fix accordingly (model ID, permissions, payload size)","Verify IAM permissions for bedrock:InvokeModelWithResponseStream/InvokeModel on the model","Check the model is available and enabled in the configured AWS region","If throttled (TooManyRequests), add retries/backoff or request a quota increase"],"exampleFix":"// before\nmodel: \"anthropic.claude-v2\" // not available in region\n// after\nmodel: \"anthropic.claude-3-5-sonnet-20240620-v1:0\" // enabled in us-east-1","handlingStrategy":"retry","validationCode":"// Pre-flight: ensure the model exists and credentials work\nconst ok = await bedrock.listFoundationModels();\nconst valid = ok.modelSummaries?.some(m => m.modelId === MODEL_ID);","typeGuard":"function isBedrockServiceError(e: unknown): e is { name: string; message: string } {\n  return typeof e === 'object' && e !== null && 'message' in e;\n}","tryCatchPattern":"try {\n  await bedrock.invoke(req);\n} catch (e) {\n  if (e.name === 'ThrottlingException') await backoffRetry();\n  else if (e.name === 'AccessDeniedException') checkIamPermissions();\n  else throw e;\n}","preventionTips":["Validate model IDs against the region's available models","Attach least-privilege IAM policies for bedrock:InvokeModel","Enable retry with exponential backoff for throttling","Match token limits of the chosen model before sending large prompts"],"tags":["aws","bedrock","ai","api-error"],"backgroundTag":"aws-service-error","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}