From e0b10aa58ca8ff54fba59a851c220ae4c36c687b Mon Sep 17 00:00:00 2001
From: Bjarke Madsen <bjarke@nordu.net>
Date: Mon, 4 Sep 2023 14:18:17 +0200
Subject: [PATCH] Don't validate joblog:cached-response values

---
 inventory_provider/routes/jobs.py   | 11 +++++------
 inventory_provider/tasks/monitor.py |  8 ++++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py
index 019c1f88..9b252d1f 100644
--- a/inventory_provider/routes/jobs.py
+++ b/inventory_provider/routes/jobs.py
@@ -53,10 +53,10 @@ TASK_LOG_RESPONSE_SCHEMA = {
     "$schema": "https://json-schema.org/draft-07/schema#",
     "type": "object",
     "properties": {
-      "pending": {"type": "array", "items": {"type": "string"}},
-      "errors": {"type": "array", "items": {"type": "string"}},
-      "failed": {"type": "array", "items": {"type": "string"}},
-      "warnings": {"type": "array", "items": {"type": "string"}},
+        "pending": {"type": "array", "items": {"type": "string"}},
+        "errors": {"type": "array", "items": {"type": "string"}},
+        "failed": {"type": "array", "items": {"type": "string"}},
+        "warnings": {"type": "array", "items": {"type": "string"}},
     },
     "required": ["pending", "errors", "failed", "warnings"],
     "additionalProperties": False
@@ -198,8 +198,7 @@ def load_task_log():
         }
 
         found_tasks = False
-        for task in monitor.load_task_log(
-                current_app.config['INVENTORY_PROVIDER_CONFIG']).values():
+        for task in monitor.load_task_log(current_app.config['INVENTORY_PROVIDER_CONFIG'], {cache_key}).values():
 
             found_tasks = True
 
diff --git a/inventory_provider/tasks/monitor.py b/inventory_provider/tasks/monitor.py
index 258c7511..4d7eed5d 100644
--- a/inventory_provider/tasks/monitor.py
+++ b/inventory_provider/tasks/monitor.py
@@ -102,7 +102,7 @@ def run():
 
     with app.connection() as connection:
         recv = app.events.Receiver(connection, handlers={
-                '*': _log_event
+            '*': _log_event
         })
         recv.capture(limit=None, timeout=None, wakeup=True)
 
@@ -163,7 +163,7 @@ def _redis_client_proc(key_queue, value_queue, config_params):
         value_queue.put(None)
 
 
-def load_task_log(config_params, ignored_keys=[]):
+def load_task_log(config_params, ignored_keys=None):
     """
     load the task log in a formatted dictionary:
       keys are task uuid's
@@ -178,6 +178,10 @@ def load_task_log(config_params, ignored_keys=[]):
     :param ignored_keys: list of keys to ignore if found
     :return:
     """
+
+    if ignored_keys is None:
+        ignored_keys = set()
+
     response_queue = queue.Queue()
 
     threads = []
-- 
GitLab