feat(ai): link AWS data retention docs in Bedrock validation errors
When Bedrock rejects a request with "data retention mode '<mode>' is not available for this model", append a pointer to the AWS data retention documentation so users can configure a supported mode.
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
||||||
|
|
||||||
- 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)).
|
- 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)).
|
||||||
|
|||||||
@@ -290,6 +290,13 @@ const BEDROCK_ERROR_PREFIXES: Record<string, string> = {
|
|||||||
ServiceUnavailableException: "Service unavailable",
|
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.
|
* Format a Bedrock error with a human-readable prefix.
|
||||||
* AWS SDK exceptions (both from `client.send()` and from stream event items)
|
* AWS SDK exceptions (both from `client.send()` and from stream event items)
|
||||||
@@ -299,11 +306,14 @@ const BEDROCK_ERROR_PREFIXES: Record<string, string> = {
|
|||||||
*/
|
*/
|
||||||
function formatBedrockError(error: unknown): string {
|
function formatBedrockError(error: unknown): string {
|
||||||
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
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) {
|
if (error instanceof BedrockRuntimeServiceException) {
|
||||||
const prefix = BEDROCK_ERROR_PREFIXES[error.name] ?? error.name;
|
const prefix = BEDROCK_ERROR_PREFIXES[error.name] ?? error.name;
|
||||||
return `${prefix}: ${message}`;
|
return `${prefix}: ${message}${dataRetentionHint}`;
|
||||||
}
|
}
|
||||||
return message;
|
return `${message}${dataRetentionHint}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user