Conversation
Greptile SummaryThis PR makes file deletion more resilient during TTL-driven chat session cleanup by introducing an Key changes:
Confidence Score: 5/5Safe to merge; the one remaining finding is a misleading log message in an edge-case error path, not a correctness issue. All changes are targeted, well-tested, and backward-compatible (error_on_missing defaults to True). The only finding is a P2 style issue: the outer except in tasks.py has a stale log message after the inner try/except was added. No data integrity, security, or runtime correctness issues were found. backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py — outer except log message should be updated to reflect what it actually catches now. Important Files Changed
Sequence DiagramsequenceDiagram
participant T as TTL Task
participant DB as DB (chat.py)
participant FS as FileStore
T->>DB: get_chat_sessions_older_than()
DB-->>T: [(user_id, session_id), ...]
loop Each session (individual try/except)
T->>DB: delete_chat_session(hard_delete=True)
DB->>FS: delete_file(error_on_missing=False)
alt File exists
FS-->>DB: deleted OK
else File already gone
FS-->>DB: silent return (no error)
end
DB-->>T: session deleted
note over T: Exception → log & continue
end
|
There was a problem hiding this comment.
1 issue found across 5 files
Confidence score: 3/5
- There is a concrete reliability risk in
backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py: catching broadExceptioncan silently mask real deletion failures instead of surfacing them. - Because this issue is high severity (7/10) with high confidence (9/10), the merge risk is moderate rather than minimal, even though it appears localized to one task path.
- Pay close attention to
backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py- narrow exception handling to the known missing-file case and re-raise unexpected errors.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py">
<violation number="1" location="backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py:51">
P1: Catching `Exception` here is too broad and hides real deletion failures; only the known missing-file case should be tolerated, and unexpected errors should be re-raised.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| include_deleted=True, | ||
| hard_delete=True, | ||
| ) | ||
| except Exception: |
There was a problem hiding this comment.
P1: Catching Exception here is too broad and hides real deletion failures; only the known missing-file case should be tolerated, and unexpected errors should be re-raised.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/ee/onyx/background/celery/tasks/ttl_management/tasks.py, line 51:
<comment>Catching `Exception` here is too broad and hides real deletion failures; only the known missing-file case should be tolerated, and unexpected errors should be re-raised.</comment>
<file context>
@@ -39,14 +39,20 @@ def perform_ttl_management_task(
+ include_deleted=True,
+ hard_delete=True,
+ )
+ except Exception:
+ logger.exception(
+ "Failed to delete chat session "
</file context>
🖼️ Visual Regression Report
|
Description
No longer error on filestore delete when file is missing during ttl cleanup task (since we want the file to be gone)
How Has This Been Tested?
new tests
Additional Options
Summary by cubic
Make file deletes tolerant when the file is already gone during TTL cleanup and chat purges. Adds an
error_on_missingflag toFileStore.delete_fileand makes the TTL task continue on per-session failures.Bug Fixes
error_on_missingtoFileStore.delete_file; TTL and chat cleanup call it withFalseso missing files don’t fail the job.S3BackedFileStoreandPostgresBackedFileStorehonor the flag and skip raises when the file/content is missing; new unit tests cover this.Migration
FileStore, updatedelete_file(self, file_id: str, error_on_missing: bool = True, db_session: Session | None = None)to match the new signature.Written for commit 1a43a97. Summary will update on new commits.