Skip to content
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

Merged
merged 3 commits into from
Mar 7, 2024

Conversation

daniel-goldstein
Copy link
Contributor

@daniel-goldstein daniel-goldstein commented Mar 1, 2024

Fixes #14350

ehigham
ehigham previously requested changes Mar 5, 2024
try:
validate_job_groups(job_group_specs)
except ValidationError as e:
raise web.HTTPBadRequest(reason=e.reason)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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!

Copy link
Member

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.

Copy link
Contributor Author

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

@hail-ci-robot hail-ci-robot merged commit 626383a into hail-is:main Mar 7, 2024
2 checks passed
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.

[batch] Type checker for dictionaries causes a 500 on failure
3 participants