Skip to content

Conversation

vrdn-23
Copy link
Contributor

@vrdn-23 vrdn-23 commented Sep 24, 2025

What does this PR do?

This fixes the error code returned by the TEI server when sending in empty inputs. Currently it returns error code 413, which is actually used for indicating the payload being too big.

This PR fixes it such that the error code returned is 400 (which was the original intention of #413), which is appropriate for a request with empty inputs.

Fixes #365

Before PR

~/dev/open-source-help/text-embeddings-inference vidamoda/fix-error-code *2 !3 ?7 > curl -i http://localhost:8080/v1/embeddings -H 'Content-Type: application/json' -d '{"input": []}'         py 3.8.14 15:47:02
HTTP/1.1 413 Payload Too Large
content-type: application/json
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
content-length: 93
date: Wed, 24 Sep 2025 22:52:53 GMT

{"message":"Input validation error: `inputs` cannot be empty","code":413,"type":"Validation"}%

After PR

~/dev/open-source-help/text-embeddings-inference vidamoda/fix-error-code *2 ?7 > curl -i http://localhost:8080/v1/embeddings -H 'Content-Type: application/json' -d '{"input": []}'                                              py 3.8.14 16:38:50
HTTP/1.1 400 Bad Request
content-type: application/json
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
content-length: 88
date: Wed, 24 Sep 2025 23:38:57 GMT

{"message":"Input validation error: `inputs` cannot be empty","code":400,"type":"Empty"}%  

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline?
  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the documentation guidelines.
  • Did you write any new necessary tests? If applicable, did you include or update the insta snapshots?

Who can review?

@Narsil @alvarobartt @kozistr

alvarobartt
alvarobartt previously approved these changes Sep 25, 2025
Co-authored-by: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com>
@vrdn-23
Copy link
Contributor Author

vrdn-23 commented Sep 25, 2025

@alvarobartt Committed your suggestion! May I have another boop? 🙃

Copy link
Contributor

@kozistr kozistr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! great work!

@alvarobartt alvarobartt merged commit 82d8560 into huggingface:main Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better HTTP Status Code for Empty Requests
3 participants