Whenever validation errors occur in any of the API endpoints, a data structure will be returned containing all of the errors we encountered, so you can take corrective action and resubmit the request. The error structure is designed to be understandable for humans as well as computable.
Each error has the following components:
- msg: The error message which occurred.
-
loc:
The location of the error in relation to the incoming request. This is an
array of string keys and integer array indices which traces the path from
the input to the invalid data. For example, if a invalid sample ID was given
for a sample when creating an order, the location might be
[“body”, “order”, “samples”, 0, “sample_id”]
where the 0 represents the index in the samples array of the invalid sample. - type: A key representing the type of error which occurred. This will either be type_error or value_error, possibly followed by a period and an additional key.
- ctx: Some types of errors provide additional context as a mapping of keys/value pairs. When ctx is present, it was combined with a template to generate the msg.