-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Serve] Return 400 response code for malformed Serve configs sent via REST API #31379
[Serve] Return 400 response code for malformed Serve configs sent via REST API #31379
Conversation
Signed-off-by: Shreyas Krishnaswamy <shrekris@anyscale.com>
@@ -115,8 +115,15 @@ async def delete_serve_application(self, req: Request) -> Response: | |||
async def put_all_deployments(self, req: Request) -> Response: | |||
from ray.serve.schema import ServeApplicationSchema | |||
from ray.serve._private.api import serve_start | |||
from pydantic import ValidationError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I delayed the pydantic
import, so it doesn't become a dependency for the dashboard.
except ValidationError as e: | ||
return Response( | ||
status=400, | ||
text=repr(e), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used repr
instead of str
since str
sometimes fails for Unicode exceptions (see this StackOverflow thread for more info).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
… REST API (#31379) When users submit a malformed Serve config (e.g. with invalid fields) via `PUT` request, they receive a 500 error. This change makes the REST API return a 400 (unretryable) error instead.
… REST API (ray-project#31379) When users submit a malformed Serve config (e.g. with invalid fields) via `PUT` request, they receive a 500 error. This change makes the REST API return a 400 (unretryable) error instead. Signed-off-by: tmynn <hovhannes.tamoyan@gmail.com>
Signed-off-by: Shreyas Krishnaswamy shrekris@anyscale.com
Why are these changes needed?
When users submit a malformed Serve config (e.g. with invalid fields) via
PUT
request, they receive a 500 error. This change makes the REST API return a 400 (unretryable) error instead.Related issue number
Closes #31370
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.test_serve_agent.py
.