From 6f26b4b5963840fbef1891e82cfb30649e91b792 Mon Sep 17 00:00:00 2001 From: Raphael <155643707+rw-bsi@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:59:36 +0100 Subject: [PATCH] Fix issue with schema validation Ignoring non-JSON lines --- backend/apps/ifc_validation/tasks.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/apps/ifc_validation/tasks.py b/backend/apps/ifc_validation/tasks.py index efff6e5..462c465 100644 --- a/backend/apps/ifc_validation/tasks.py +++ b/backend/apps/ifc_validation/tasks.py @@ -568,7 +568,15 @@ def schema_validation_subtask(self, prev_result, id, file_name, *args, **kwargs) task.mark_as_failed(err) raise - output = list(filter(None, proc.stdout.split("\n"))) + # schema check returns either multiple JSON lines, or a single line message, or nothing. + def is_schema_error(line): + try: + json.loads(line) # ignoring non-JSON messages + except ValueError: + return False + return True + + output = list(filter(is_schema_error, proc.stdout.split("\n"))) # success = (len(output) == 0) # tfk: if we mark this task as failed we don't do the instance population either. # marking as failed should probably be reserved for blocking errors (prerequisites)