-
Notifications
You must be signed in to change notification settings - Fork 605
Fix POST response status codes #1212
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vishalbollu
reviewed
Jul 10, 2020
vishalbollu
reviewed
Jul 13, 2020
vishalbollu
approved these changes
Jul 15, 2020
docs/deployments/predictors.md
Outdated
The `payload` parameter is parsed according to the `Content-Type` header in the request. For `Content-Type: application/json`, `payload` will be the parsed JSON body. For `Content-Type: multipart/form` or `Content-Type: application/x-www-form-urlencoded`, `payload` will be `starlette.datastructures.FormData` (key-value pairs where the value is a `string` for form data, or `starlette.datastructures.UploadFile` for file uploads, see [Starlette's documentation](https://www.starlette.io/requests/#request-files)). For all other `Content-Type` values, `payload` will be the raw `bytes` of the request body. | ||
Your API can accept requests with different types of payloads such as `JSON`-parseable, `bytes` or `starlette.datastructures.FormData` data. Navigate to the [API requests](#api-requests) section to learn about how headers can be used to change the type of `payload` that is passed into your `predict` function. | ||
|
||
Your API can be configured to respond with different types of payload such as `JSON`-parseable, `string`, and `bytes` objects. Navigate to the [API responses](#api-responses) section to learn about how your API can respond with different response codes and content-types. |
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.
Your predictor can return different types of objects such as JSON
-parseable, string
, and bytes
objects. Navigate to the API responses section to learn about how to configure your predictor to respond with different response codes and content-types.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1208.
It appears that with the FastAPI web framework, throwing exceptions in the middleware is not the intended way of handling errors. It is assumed that any exceptions occurring in the middleware are gracefully handled, meaning that instead of throwing exceptions, responses are expected to be returned instead. It is therefore assumed that any exceptions occurring in the middleware are just implementation errors and thus returning the 500 status code is acceptable (aka what we've been returning so far).
The only place where the
@app.exception_handler
handlers are used is right after the middleware once an API route has already been taken (e.g.predict
orsummary
). In order for those handlers to work, an API route handler would have to throw an exception that would match one of the handlers' exceptions.A couple of resources that helped me with this are the following:
checklist:
make test
andmake lint
summary.md
(view in gitbook after merging)