Skip to content

Conversation

@paullizer
Copy link
Contributor

(v0.235.022)

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_updated field, but query was looking for last_activity_at (used by conversations).
    • Root Cause 2: Date format mismatch - documents store YYYY-MM-DDTHH:MM:SSZ but query used Python's .isoformat() with +00:00 suffix.
    • 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_reason parameter instead of additional_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)

Copy link
Collaborator

@Bionic711 Bionic711 left a comment

Choose a reason for hiding this comment

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

Just the one question about the lack of general exception handling in the one call.

Now uses retention_policy_next_run timestamp - Compares current time against the stored next scheduled time. If current time >= next scheduled time, it runs.

Reduced check interval from 1 hour to 5 minutes - More responsive scheduling, ensures it catches the scheduled time promptly.

Better fallback logic - If next_run can't be parsed, falls back to checking last_run (23-hour threshold).

Runs immediately if never run before - If there's no last_run or next_run, it will execute on the first check.
@paullizer paullizer merged commit 3b0aa7f into Development Jan 17, 2026
3 checks passed
@paullizer paullizer deleted the Retention-excecution-activity-log branch January 17, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants