v0.235.025
Bug Fixes
-
Retention Policy Document Deletion Fix
- Fixed critical bug where retention policy execution failed when attempting to delete aged documents, while conversation deletion worked correctly.
- Root Cause 1: Documents use
last_updatedfield, but query was looking forlast_activity_at(used by conversations). - Root Cause 2: Date format mismatch - documents store
YYYY-MM-DDTHH:MM:SSZbut query used Python's.isoformat()with+00:00suffix. - Root Cause 3: Duplicate column in SELECT clause when
partition_field='user_id'caused query errors. - Root Cause 4: Activity logging called with incorrect
deletion_reasonparameter instead ofadditional_context. - Files Modified:
functions_retention_policy.py(query field names, date format, SELECT clause, activity logging). - (Ref:
delete_aged_documents(), retention policy execution, Cosmos DB queries)
-
Retention Policy Scheduler Fix
- Fixed automated retention policy scheduler not executing at the scheduled time.
- Root Cause 1: Hour-matching approach was unreliable - only ran if check happened exactly during the execution hour (e.g., 2 AM), but 1-hour sleep intervals could miss the entire window.
- Root Cause 2: Check interval too long (1 hour) meant poor responsiveness and high probability of missing scheduled time.
- Root Cause 3: Code ignored the stored
retention_policy_next_runtimestamp, instead relying solely on hour matching. - Solution: Now uses
retention_policy_next_runtimestamp for comparison, reduced check interval from 1 hour to 5 minutes, added fallback logic for missed executions. - Files Modified:
app.py(check_retention_policy()background task). - (Ref: retention policy scheduler, background task, scheduled execution)