Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/opl/investigator/elasticsearch_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def load(server, index, query, paths, **kwargs):
response = opl.http.get(url, headers=headers, json=data)

for item in response["hits"]["hits"]:
params = item["_source"].get("parameters", {})
logging.debug(
f"Loading data from document ID {item['_id']} with field id={item['_source']['id'] if 'id' in item['_source'] else None} or parameters.run={item['_source']['parameters']['run'] if 'run' in item['_source']['parameters'] else None}"
f"Loading data from document ID {item['_id']} with field id={item['_source'].get('id')} or parameters.run={params.get('run')}"
Comment on lines +43 to +45

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Handle non-object parameters values as well.

.get("parameters", {}) only defaults when the key is missing. A document with parameters: null (or another non-mapping value) still makes params.get("run") raise AttributeError and abort the whole load. Normalize or validate the value before logging.

Proposed fix
-        params = item["_source"].get("parameters", {})
+        params = item["_source"].get("parameters")
+        if not isinstance(params, dict):
+            params = {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
params = item["_source"].get("parameters", {})
logging.debug(
f"Loading data from document ID {item['_id']} with field id={item['_source']['id'] if 'id' in item['_source'] else None} or parameters.run={item['_source']['parameters']['run'] if 'run' in item['_source']['parameters'] else None}"
f"Loading data from document ID {item['_id']} with field id={item['_source'].get('id')} or parameters.run={params.get('run')}"
params = item["_source"].get("parameters")
if not isinstance(params, dict):
params = {}
logging.debug(
f"Loading data from document ID {item['_id']} with field id={item['_source'].get('id')} or parameters.run={params.get('run')}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@core/opl/investigator/elasticsearch_loader.py` around lines 43 - 45, Update
the parameters handling in the document-loading flow to normalize or validate
item["_source"].get("parameters", {}) before calling params.get("run"). Ensure
null and other non-mapping values are safely treated as an empty mapping so the
logging statement cannot raise AttributeError, while preserving valid parameter
mappings.

)
tmpfile = tempfile.NamedTemporaryFile(prefix=item["_id"], delete=False).name
sd = opl.status_data.StatusData(
Expand Down
Loading