From 4da60215f0dfb4fc8cd39a2ecefba0ad270dbe60 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 9 Jan 2022 15:43:12 +0000 Subject: [PATCH] Gateway/errors: Tag FAIL if a zlib.error --- schemas/README-EDDN-schemas.md | 23 +++++++++++++---------- src/eddn/Gateway.py | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/schemas/README-EDDN-schemas.md b/schemas/README-EDDN-schemas.md index a1d6da7..388a498 100644 --- a/schemas/README-EDDN-schemas.md +++ b/schemas/README-EDDN-schemas.md @@ -312,27 +312,30 @@ make a valid request" responses you might experience the following: #### EDDN Gateway responses 1. `400` - `Bad Request` - this can be for a variety of reasons, and should come with a response body with a `FAIL: ` prefix: - 1. `FAIL: JSON parsing: ` - the + 1. `FAIL: zlib.error: ` - A failure to decompress a message that + claimed to be compressed. + + 2. `FAIL: JSON parsing: ` - the request 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) - ``` - 2. `FAIL: ["]` - the JSON + ``` + FAIL: JSON parsing: Expecting property name enclosed in double quotes: line 1 column 2 (char 1) + ``` + 3. `FAIL: ["]` - the JSON message failed to pass schema validation. e.g. - ``` - FAIL: [] - ``` + ``` + FAIL: [] + ``` - 3. Other python exception message, e.g. if a message appeared to be + 4. Other python exception message, e.g. if a message appeared to be gzip compressed, but a failure was experienced when attempting to decompress it. **NB: As of 2022-07-01 such messages won't have the `FAIL: ` prefix.** See [#161 - Gateway: Improve reporting of 'misc' errors ](https://github.com/EDCD/EDDN/issues/161) for any progress/resolution on this. -2. `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 a schema, or an entirely deprecated schema. e.g. diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index 7541000..f34c514 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -300,7 +300,7 @@ def upload(): response.status = 400 logger.error("MalformedUploadError from %s: %s" % (get_remote_address(), exc.message)) - return 'FAIL: ' + exc.message + return 'FAIL: Malformed Upload: ' + exc.message statsCollector.tally("inbound") return parse_and_error_handle(message_body)