-
Notifications
You must be signed in to change notification settings - Fork 248
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
[batch] 400 on bad job group specs instead of 500 #14389
[batch] 400 on bad job group specs instead of 500 #14389
Conversation
e03eca5
to
a689656
Compare
a689656
to
da3ef9e
Compare
batch/batch/front_end/front_end.py
Outdated
try: | ||
validate_job_groups(job_group_specs) | ||
except ValidationError as e: | ||
raise web.HTTPBadRequest(reason=e.reason) |
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.
Could this be moved up the stack? I feel like once execution reaches this point, the request itself should have been well-formed at least?
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.
Ya it could be moved up one level to the route handler. I changed the other resource creation methods to match. Slightly repetitive, but ensures we never touch the database if anything about the request is malformed. Unfortunately we're not using strict mode for pyright and json_request
returns Any
(so passing its output to other methods will always pass the typechecker regardless of the signature) so I'm not so sure how we can enforce in the type checker that the specs were validated.
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.
That's a nice improvement!
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.
Do we use an openapi spec for the batch http api? I've used tools that parse requests against a spec and only pass valid requests onto you in other environments - doubtless something like this exists for python.
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.
we certainly could, but we no we don't it's pretty vanilla
Fixes #14350