From 6cb309f72b05c767ea5da69293e05bc23a401694 Mon Sep 17 00:00:00 2001 From: Daniyar <99352497+Spectorisimo@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:22:07 +0500 Subject: [PATCH] Fix AttributeError when event_date is None in fact_extraction (#875) * Fix AttributeError when event_date is None in fact_extraction `_extract_facts_from_chunk` crashes with `'NoneType' object has no attribute 'isoformat'` when retaining documents without a timestamp. Two locations fixed: - Line 1058: debug log called `event_date.isoformat()` without a None check - Line 921: `parse_datetime_flexible()` can return None, so re-check before calling `.strftime()` / `.isoformat()` Fixes #874 * Revert unnecessary None guard on line 921 The original `if event_date is not None:` already guards that block. Only line 1058 needed the fix. --- .../hindsight_api/engine/retain/fact_extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hindsight-api-slim/hindsight_api/engine/retain/fact_extraction.py b/hindsight-api-slim/hindsight_api/engine/retain/fact_extraction.py index e9e6ebaa..4c54f8a3 100644 --- a/hindsight-api-slim/hindsight_api/engine/retain/fact_extraction.py +++ b/hindsight-api-slim/hindsight_api/engine/retain/fact_extraction.py @@ -1055,7 +1055,7 @@ async def _extract_facts_from_chunk( f"LLM response missing 'facts' field or returned empty list. " f"Response: {extraction_response_json}. " f"Input: " - f"date: {event_date.isoformat()}, " + f"date: {event_date.isoformat() if event_date else 'unset'}, " f"context: {context if context else 'none'}, " f"text: {chunk}" )