Error Responses#
Error Responses
In the event of an unexpected error occuring within the protocol, the AMVP server MUST respond with to AMVP client requests with a JSON encoded message following the format below.
{
"amvVersion": "{amvp-version}",
{
"category": 0,
"description": "{description of category}",
"errors": [
{
"code": 1,
"messages": ["First message", "Second message", "..."]
},
{
"code": 2,
"messages": ["First message", "Second message", "..."]
},
]
}
}
The integer value for "category" MUST match a category code defined in table 1 below.
Individual error codes are defined in each section of the specification. Codes that are used between different sections should still appear in each section. If an error occurs that is not defined in the specification, the AMVP server MUST use an error code of 0. If multiple error codes exist that could describe a given error, the AMVP server SHALL use the one most specific to that situation.
An error response from the AMVP server MUST have at least a single error object within the "errors" array. The AMVP server also SHALL include at least one message for each error object, and SHOULD include as many messages as are relevant to each object. The AMVP server MAY also add additional key/value pairs to each error object depending on the implementation, but any added key/value pairs MUST be relevant to describing or troubleshooting the error. For the sake of consistency, the AMVP server MUST NOT include errors from different categories of errors in a single response.
Category Code | Description String | HTTP[S] Code | Protocol Descrption |
---|---|---|---|
0 |
"General or Undefined Error" |
For errors that do not fit into another category |
|
1 |
"Authentication and/or Authroization Error" |
403 |
For errors caused by an AMVP client having insufficient credentials to access the requested endpoint or resource |
2 |
"Malformed Payload Error" |
400 |
For errors caused by syntactically incorrect requests. Possible examples include invalid JSON or invalid HTTP[S] request headers |
3 |
"Invalid Data or Request Error" |
422 |
For errors caused by requests that are properly formatted but semantically incorrect. This includes errors related to a client sending data that is invalid within the bounds of the protocol; for example, out of bounds registration values |
4 |
"Server Error" |
For unexpected errors generated by server logic or outages |
Other sections of the specification may define required HTTP[S] codes for specific scenarios that do not have one defined in table 1. If an HTTP[S] code is not specified for a given error or category of errors, the AMVP server SHOULD use an HTTP[S] code that is most relevant to the error being returned to the AMVP client. While AMVP clients MAY use HTTP[S] codes to determine the general status of a request, AMVP clients SHOULD NOT depend on HTTP[S] codes for differentiating between types of errors; instead, they should rely on the contents of the response body described above.