Spaces:
Running
Running
Update services/report_data_handler.py
Browse files
services/report_data_handler.py
CHANGED
@@ -240,6 +240,17 @@ def save_actionable_okrs(org_urn: str, actionable_okrs: Dict[str, Any], report_i
|
|
240 |
|
241 |
try:
|
242 |
objectives_data = actionable_okrs.get("okrs", [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
if not objectives_data:
|
244 |
logger.warning(f"No OKRs found in the input for org_urn: {org_urn}. Aborting save process.")
|
245 |
return
|
@@ -272,4 +283,3 @@ def save_actionable_okrs(org_urn: str, actionable_okrs: Dict[str, Any], report_i
|
|
272 |
|
273 |
except Exception as e:
|
274 |
logger.exception(f"An unhandled exception occurred during the save_actionable_okrs orchestration for org_urn {org_urn}: {e}")
|
275 |
-
|
|
|
240 |
|
241 |
try:
|
242 |
objectives_data = actionable_okrs.get("okrs", [])
|
243 |
+
|
244 |
+
# Defensive check: If data is a string, try to parse it as JSON.
|
245 |
+
if isinstance(objectives_data, str):
|
246 |
+
logger.warning("The 'okrs' data is a string. Attempting to parse as JSON.")
|
247 |
+
try:
|
248 |
+
objectives_data = json.loads(objectives_data)
|
249 |
+
logger.info("Successfully parsed 'okrs' data from JSON string.")
|
250 |
+
except json.JSONDecodeError:
|
251 |
+
logger.error("Failed to parse 'okrs' data. The string is not valid JSON.", exc_info=True)
|
252 |
+
return # Abort if data is malformed
|
253 |
+
|
254 |
if not objectives_data:
|
255 |
logger.warning(f"No OKRs found in the input for org_urn: {org_urn}. Aborting save process.")
|
256 |
return
|
|
|
283 |
|
284 |
except Exception as e:
|
285 |
logger.exception(f"An unhandled exception occurred during the save_actionable_okrs orchestration for org_urn {org_urn}: {e}")
|
|