From 4da4ee64119b869431bb27c45890f5e8361349ab Mon Sep 17 00:00:00 2001 From: Eric Huang Date: Tue, 25 Mar 2025 15:56:55 -0700 Subject: [PATCH] fix: raise error when request param failed to convert # What does this PR do? similar to #1339 ## Test Plan LLAMA_STACK_CONFIG=dev pytest -s -v tests/integration/ --safety-shield meta-llama/Llama-Guard-3-8B --text-model accounts/fireworks/models/llama-v3p1-8b-instruct --- llama_stack/distribution/library_client.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/llama_stack/distribution/library_client.py b/llama_stack/distribution/library_client.py index 565f22ae0..c51217b90 100644 --- a/llama_stack/distribution/library_client.py +++ b/llama_stack/distribution/library_client.py @@ -83,17 +83,15 @@ def convert_to_pydantic(annotation: Any, value: Any) -> Any: item_type = get_args(annotation)[0] try: return [convert_to_pydantic(item_type, item) for item in value] - except Exception: - logger.error(f"Error converting list {value} into {item_type}") - return value + except Exception as e: + raise ValueError(f"Failed to convert list {value} into {item_type}: {e}") from e elif origin is dict: - key_type, val_type = get_args(annotation) + val_type = get_args(annotation) try: return {k: convert_to_pydantic(val_type, v) for k, v in value.items()} - except Exception: - logger.error(f"Error converting dict {value} into {val_type}") - return value + except Exception as e: + raise ValueError(f"Failed to convert dict {value} into {val_type}: {e}") from e try: # Handle Pydantic models and discriminated unions