fides icon indicating copy to clipboard operation
fides copied to clipboard

Add custom HTTP error types to FastAPI routes

Open ssangervasi opened this issue 3 years ago • 0 comments

Is your feature request related to a specific problem?

There are a number of APIs that raise HTTPExceptions which are not included in our OpenAPI docs. Example: when AWS auth fails, the API will return 403 ConnectorAuthFailureException. Our API only lists the default FastAPI responses: 200 with the model schema, 400 with a detail string that has no schema, or 422 for param validation.

Describe the solution you'd like

FastAPI supports "Additional Responses" for this purpose. They are a bit verbose, but the benefit would be:

  1. Keeping clients in sync with OpenAPI type generation.
  2. Improved accuracy of the API docs.
  3. Encouraging standardizing error definitions in the python codebase.

Describe alternatives you've considered, if any

Both fidesops and fidesctl clients have custom typescript interfaces to narrowing down what the error contains, mainly to find an error string to present to the user. This is prone to getting out of sync with server.

Additional context

Originally posted by @ssangervasi in https://github.com/ethyca/fides/issues/892#issuecomment-1182131940

ssangervasi avatar Jul 12 '22 19:07 ssangervasi