fix: TTL management task no longer crashes on missing file records#9804
Draft
jcaille wants to merge 4 commits intoonyx-dot-app:mainfrom
Draft
fix: TTL management task no longer crashes on missing file records#9804jcaille wants to merge 4 commits intoonyx-dot-app:mainfrom
jcaille wants to merge 4 commits intoonyx-dot-app:mainfrom
Conversation
The TTL cleanup task would crash with a RuntimeError when trying to delete a file record that no longer exists, blocking cleanup of all remaining sessions. Two fixes: 1. Wrap file deletion in delete_messages_and_files_from_chat_session with try/except — a missing file is already the desired state, so log a warning and continue. 2. Add per-session error handling in the TTL task loop. The existing comment said "one session per delete so that we don't blow up" but the outer try/except still aborted on the first failure. Now each session deletion is individually wrapped so failures don't block cleanup of subsequent sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_chat_deletion: verifies delete_messages_and_files_from_chat_session continues when a file record is missing, and handles messages with no files - test_ttl_task: verifies perform_ttl_management_task continues deleting remaining sessions after one fails, and reports correct success status Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Prefix unused mock params with _ and type as Any - Extract shared db session mock setup into helper - Remove unused pytest import - Use module path constant to reduce repetition
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The TTL cleanup task would crash with a RuntimeError when trying to delete a file record that no longer exists, blocking cleanup of all remaining sessions.
Two fixes proposed:
Wrap file deletion in delete_messages_and_files_from_chat_session with try/except — a missing file is already the desired state, so log a warning and continue.
Add per-session error handling in the TTL task loop. The existing comment said "one session per delete so that we don't blow up" but the outer try/except still aborted on the first failure. Now each session deletion is individually wrapped so failures don't block cleanup of subsequent sessions.
Additional Options
Summary by cubic
Prevents TTL cleanup from crashing on missing file records by skipping those deletes and isolating per-session errors. Cleanup continues for all sessions and the task reports failure only if any deletion fails.
Bug Fixes
delete_messages_and_files_from_chat_session, wrap file deletes in try/except; log a warning and continue on missing files.perform_ttl_management_task, handle each session in try/except, count failures, and set success tofailures == 0.Refactors
Written for commit 569fef2. Summary will update on new commits.