From 0b6c95dda0305ddbfa986d684b7169d773c79258 Mon Sep 17 00:00:00 2001 From: Burak Varli Date: Tue, 9 Jun 2026 19:37:57 +0000 Subject: [PATCH] feat(ai): link AWS data retention docs in Bedrock validation errors When Bedrock rejects a request with "data retention mode '' is not available for this model", append a pointer to the AWS data retention documentation so users can configure a supported mode. --- packages/ai/CHANGELOG.md | 2 ++ packages/ai/src/providers/amazon-bedrock.ts | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index f757493c..5af75b1e 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- When Amazon Bedrock rejects an unsupported data retention mode, the error now links the AWS data retention documentation ([#5561](https://github.com/earendil-works/pi/pull/5561) by [@unexge](https://github.com/unexge)). + ### Fixed - Fixed Claude Fable 5 thinking-off requests to omit Anthropic's unsupported `thinking.type: "disabled"` payload ([#5567](https://github.com/earendil-works/pi/pull/5567) by [@tmustier](https://github.com/tmustier)). diff --git a/packages/ai/src/providers/amazon-bedrock.ts b/packages/ai/src/providers/amazon-bedrock.ts index b022b522..a4ace1c2 100644 --- a/packages/ai/src/providers/amazon-bedrock.ts +++ b/packages/ai/src/providers/amazon-bedrock.ts @@ -290,6 +290,13 @@ const BEDROCK_ERROR_PREFIXES: Record = { ServiceUnavailableException: "Service unavailable", }; +/** + * Some models reject the account/profile's configured Bedrock data retention mode + * (e.g. "data retention mode 'default' is not available for this model"). Point + * users at the AWS docs explaining how to configure a supported mode. + */ +const BEDROCK_DATA_RETENTION_DOCS_URL = "https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html"; + /** * Format a Bedrock error with a human-readable prefix. * AWS SDK exceptions (both from `client.send()` and from stream event items) @@ -299,11 +306,14 @@ const BEDROCK_ERROR_PREFIXES: Record = { */ function formatBedrockError(error: unknown): string { const message = error instanceof Error ? error.message : JSON.stringify(error); + const dataRetentionHint = /data retention mode/i.test(message) + ? ` See ${BEDROCK_DATA_RETENTION_DOCS_URL} for supported data retention modes.` + : ""; if (error instanceof BedrockRuntimeServiceException) { const prefix = BEDROCK_ERROR_PREFIXES[error.name] ?? error.name; - return `${prefix}: ${message}`; + return `${prefix}: ${message}${dataRetentionHint}`; } - return message; + return `${message}${dataRetentionHint}`; } /**