Error Handling

Status Codes

Data connectors should use standard HTTP error codes to signal error conditions back to the Hasura server. In particular, the following error codes should be used in the indicated scenarios:

Response CodeMeaningUsed when
200OKThe request was handled successfully according to this specification .
400Bad RequestThe request did not match the data connector's expectation based on this specification.
403ForbiddenThe request could not be handled because a permission check failed - for example, a mutation might fail because a check constraint was not met.
409ConflictThe request could not be handled because it would create a conflicting state for the data source - for example, a mutation might fail because a foreign key constraint was not met.
422Unprocessable ContentThe request could not be handled because, while the request was well-formed, it was not semantically correct. For example, a value for a custom scalar type was provided, but with an incorrect type.
500Internal Server ErrorThe request could not be handled because of an error on the server
501Not SupportedThe request could not be handled because it relies on an unsupported capability. Note: this ought to indicate an error on the caller side, since the caller should not generate requests which are incompatible with the indicated capabilities.
502Bad GatewayThe request could not be handled because an upstream service was unavailable or returned an unexpected response, e.g., a connection to a database server failed

Response Body

Data connectors should return an ErrorResponse as JSON in the response body, in the case of an error.