Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/llm/src/preprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,11 +1096,13 @@ impl OpenAIPreprocessor {
let _nvtx = dynamo_nvtx_range!("preprocess.template");
self.apply_template(request)
.map_err(|e| {
let msg = format!("Failed to apply prompt template: {e}");
// Template rendering errors (e.g., invalid message role, malformed chat history)
// are client validation errors and should return 400, not 500.
// Note: We don't use .cause(e) because anyhow::Error doesn't implement
// std::error::Error in the way DynamoErrorBuilder::cause expects.
DynamoError::builder()
.error_type(ErrorType::InvalidArgument)
.message(msg)
.cause(e)
.message(format!("Failed to apply prompt template: {e:#}"))
.build()
.into()
})?
Expand Down
Loading