mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(mistral): reject malformed base64 audio_data with strict validation
This commit is contained in:
parent
676f841534
commit
7c4cf2dcff
2 changed files with 2 additions and 2 deletions
|
|
@ -172,7 +172,7 @@ class MistralTextToSpeechConfig(BaseTextToSpeechConfig):
|
|||
headers=raw_response.headers,
|
||||
)
|
||||
try:
|
||||
audio_bytes: Final = base64.b64decode(audio_b64)
|
||||
audio_bytes: Final = base64.b64decode(audio_b64, validate=True)
|
||||
except ValueError:
|
||||
raise MistralTextToSpeechException(
|
||||
status_code=500,
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ def test_transform_response_invalid_base64_raises():
|
|||
config: Final = MistralTextToSpeechConfig()
|
||||
raw_response: Final = httpx.Response(
|
||||
status_code=200,
|
||||
json={"audio_data": "!!!not-base64!!!"},
|
||||
json={"audio_data": "QUJD!QUJD"},
|
||||
request=httpx.Request("POST", SPEECH_URL),
|
||||
)
|
||||
with pytest.raises(MistralTextToSpeechException, match="base64"):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue