Gateway/errors: 'Schema Validation' properly tagged and documented

This commit is contained in:
Athanasius 2022-01-09 16:02:28 +00:00
parent e111fb8415
commit ccde820ba7
No known key found for this signature in database
GPG Key ID: AE3E527847057C7D
2 changed files with 25 additions and 14 deletions

View File

@ -320,28 +320,32 @@ make a valid request" responses you might experience the following:
key. key.
3. `FAIL: JSON parsing: <detail>` - the 3. `FAIL: JSON parsing: <detail>` - the
request couldn't be parsed as valid JSON. e.g. message couldn't be parsed as valid JSON. e.g.
``` ```
FAIL: JSON parsing: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) FAIL: JSON parsing: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
``` ```
4. `FAIL: Outdated Schema: <detail>` - message cites a schema (or 4. `FAIL: Schema Validation: <detail>` - the message failed to validate
version of) that is no longer supported. against the cited schema. e.g.
6. `FAIL: [<ValidationError: "<schema validation failure>"]` - the JSON
message failed to pass schema validation. e.g.
``` ```
FAIL: [<ValidationError: "'StarPos' is a required property">] FAIL: Schema Validation: [<ValidationError: "'StarPos' is a required property">]
``` ```
6. Other python exception message, e.g. if a message appeared to be The exact detail will be very much dependent on both the schema the
gzip compressed, but a failure was experienced when attempting to message cited and the contents of the message that failed to pass the
decompress it. **NB: As of 2022-07-01 such messages won't have the validation.
`FAIL: ` prefix.** See
[#161 - Gateway: Improve reporting of 'misc' errors ](https://github.com/EDCD/EDDN/issues/161) In particular, if the message contains a key that is tagged 'disallowed' in
for any progress/resolution on this. the schema the response will look like:
```
FAIL: Schema Validation: "[<ValidationError: "{'type': ['array', 'boolean', 'integer', 'number', 'null', 'object', 'string']} is not allowed for 'BadKey'">]"
```
This is due to the use of a JSON schema stanza that says "don't allow
any valid type for the value of this key" to trigger the error for such
disallowed keys.
3. `426` - `Upgrade Required` - You sent a message with an outdated 3. `426` - `Upgrade Required` - You sent a message with an outdated
`$schemaRef` value. This could be either an old, deprecated version of `$schemaRef` value. This could be either an old, deprecated version of
@ -350,6 +354,13 @@ make a valid request" responses you might experience the following:
``` ```
FAIL: The schema you have used is no longer supported. Please check for an updated version of your application. FAIL: The schema you have used is no longer supported. Please check for an updated version of your application.
``` ```
4. `FAIL: Outdated Schema: <detail>` - message cites a schema (or
version of) that is no longer supported.
There shouldn't be any other variants of a 'FAIL' message. If you find
any then please open an issue with as much detail as possible so we can
update this documentation.
## Receiving messages ## Receiving messages

View File

@ -265,7 +265,7 @@ def parse_and_error_handle(data):
response.status = 400 response.status = 400
statsCollector.tally("invalid") statsCollector.tally("invalid")
return "FAIL: " + str(validationResults.messages) return "FAIL: Schema Validation: " + str(validationResults.messages)
@app.route('/upload/', method=['OPTIONS', 'POST']) @app.route('/upload/', method=['OPTIONS', 'POST'])