Open e1ijah1 opened 3 days ago
The client CURL command for that example service should be:
curl -X 'POST' \
'http://localhost:3000/speed_up_audio' \
-H 'accept: audio/mp3' \
-H 'Content-Type: multipart/form-data' \
-F 'audio=@example.mp3;type=audio/mpeg' \
-F 'velocity=2' \
-o output.mp3
If you're not sure what's the API specification, try visit http://localhost:3000/
to send request with the built-in OpenAPI UI, or download the OpenAPI spec json from http://localhost:3000/docs.json
.
BentoML's built-in Python client is also very easy to use. The client call simply matches the API function definition in the service:
import bentoml
from pathlib import Path
with bentoml.SyncHTTPClient("http://localhost:3000") as client:
result = client.speed_up_audio(
audio=Path("example.mp3"),
velocity=2,
)
Describe the bug
When using the
AudioSpeedUp
example from the io-descriptors folder, uploading an audio file fails with bothContent-Type: audio/mpeg
and without a specified Content-Type. This indicates a problem with audio file handling in the io-descriptors implementation.To reproduce
Clone the BentoML repository and navigate to the examples/io-descriptors folder.
Start the
AudioSpeedUp
service:Attempt to upload an audio file using the following curl command:
The server returns a
500
status code with the following traceback:If the Content-Type header is omitted, a different error occurs:
This results in a 400 error with the following traceback:
This issue seems to be related to a lack of proper validation for audio file uploads in BentoML. A similar issue has been reported previously: https://github.com/bentoml/BentoML/issues/4651
Expected behavior
The service should accept the audio file and process it as intended.
Environment
bentoml==1.3.5
Python 3.10.14
Platform: CentOS 7