From 64bf9a5ef24a8c1f8e86797c93a39a59bb5b5758 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Thu, 16 Apr 2020 16:04:17 +0200
Subject: [PATCH] SW-907: added faulty json to exception message

---
 SAS/TMSS/src/tmss/tmssapp/validation.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/SAS/TMSS/src/tmss/tmssapp/validation.py b/SAS/TMSS/src/tmss/tmssapp/validation.py
index f1b2c9a788b..2908a80cad6 100644
--- a/SAS/TMSS/src/tmss/tmssapp/validation.py
+++ b/SAS/TMSS/src/tmss/tmssapp/validation.py
@@ -14,13 +14,18 @@ def validate_json_against_schema(json_string: str, schema: str):
     if type(schema) != str:
         schema = json.dumps(schema)
 
+    # ensure the specification and schema are both valid json in the first place
     try:
-        # ensure the specification and schema are both valid json in the first place
         json_object = json.loads(json_string)
+    except json.decoder.JSONDecodeError as e:
+        raise SchemaValidationException("Invalid JSON: %s\n%s" % (str(e), json_string))
+
+    try:
         schema_object = json.loads(schema)
     except json.decoder.JSONDecodeError as e:
-        raise SchemaValidationException("Invalid JSON: %s" % str(e))
+        raise SchemaValidationException("Invalid JSON: %s\n%s" % (str(e), schema))
 
+    # now do the actual validation
     try:
         jsonschema.validate(json_object, schema_object)
     except jsonschema.ValidationError as e:
-- 
GitLab