-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resilience evidence attachment missing #1455
base: main
Are you sure you want to change the base?
Conversation
this is a first attempt, might not be the best for now
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe pull request focuses on improving error handling and attachment retrieval across the application. Changes span both backend and frontend, introducing more robust checks for attachment existence and enhancing user feedback when attachments cannot be found. The modifications involve adding storage existence checks in the backend models and views, updating frontend components to handle attachment fetch failures, and adding a localization message for attachment-related errors. Changes
Sequence DiagramsequenceDiagram
participant Frontend
participant Backend
participant Storage
Frontend->>Backend: Request Attachment
Backend->>Storage: Check Attachment Existence
alt Attachment Exists
Storage-->>Backend: Attachment Found
Backend-->>Frontend: Return Attachment
else Attachment Not Found
Storage-->>Backend: Attachment Missing
Backend-->>Frontend: Return 404 Error
Frontend->>Frontend: Display Error Message
end
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
backend/core/views.py (2)
3134-3134
: Remove debug print statement.The commented-out print statement should be removed as it's not needed in production code.
- # print("==> ATTACHEMENT CALLED")
3138-3141
: Remove debug print statement and fix typo.The commented-out print statement should be removed and there's a typo in "ATTACHEMENT".
- # print("=============\n",evidence.attachment.name, evidence.attachment.storage.exists(evidence.attachment.name), "\n========")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
backend/core/models.py
(1 hunks)backend/core/views.py
(1 hunks)frontend/messages/en.json
(1 hunks)frontend/src/lib/components/ModelTable/EvidenceFilePreview.svelte
(2 hunks)frontend/src/routes/(app)/(third-party)/evidences/[id=uuid]/+page.svelte
(3 hunks)
🔇 Additional comments (9)
frontend/src/lib/components/ModelTable/EvidenceFilePreview.svelte (3)
Line range hint
7-11
: LGTM! Interface enhancement for better error handling.The addition of
couldFetch
to the Attachment interface enables proper tracking of attachment fetch status.
19-23
: LGTM! Robust fetch status check.The fetch status check is comprehensive, verifying both:
- HTTP response status via
res.ok
- Error message in blob content
49-50
: LGTM! User-friendly error feedback.Good addition of error message display when attachment fetch fails, using the localized message.
frontend/src/routes/(app)/(third-party)/evidences/[id=uuid]/+page.svelte (3)
19-22
: LGTM! Consistent interface enhancement.The addition of
couldFetch
to the Attachment interface maintains consistency with EvidenceFilePreview.svelte.
53-57
: LGTM! Consistent fetch status check.The fetch status check implementation matches EvidenceFilePreview.svelte, ensuring consistent behavior.
190-194
: LGTM! Consistent error handling UI.The error message display implementation aligns with EvidenceFilePreview.svelte, providing a consistent user experience.
backend/core/views.py (1)
3139-3141
: LGTM! Robust attachment existence check.The addition of
storage.exists()
check prevents the application from crashing when an attachment file is missing.frontend/messages/en.json (1)
777-777
: LGTM! Clear error message.The added message "Error: Could not find attachment." is clear and user-friendly.
backend/core/models.py (1)
1722-1724
: LGTM! Good defensive programming.The additional check for file existence in storage is a robust solution that prevents crashes when the file is missing from the storage system.
avoid crashing when the attachment is brutally removed from /db/attachments/
Summary by CodeRabbit
Release Notes
Bug Fixes
New Features
Documentation
The changes focus on improving the reliability and user experience when working with file attachments across the application.