-
Notifications
You must be signed in to change notification settings - Fork 297
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
fix: resilience evidence attachment missing #1455
Conversation
this is a first attempt, might not be the best for now
Warning Rate limit exceeded@nas-tabchiche has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 34 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
WalkthroughThe pull request enhances error handling and attachment retrieval across the application. It includes backend modifications to improve checks for attachment existence in storage, as well as frontend updates to provide clearer user feedback when attachments cannot be found. New properties and conditional rendering are introduced in the frontend components, along with 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
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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.
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: 0
🧹 Nitpick comments (1)
frontend/src/routes/(app)/(third-party)/evidences/[id=uuid]/+page.svelte (1)
50-58
: Add error handling for fetch operations.While using
res.ok
is good, the fetch operation should include error handling to gracefully handle network failures or invalid responses.Consider adding try-catch blocks:
const fetchAttachment = async () => { + try { const res = await fetch(`./${data.evidence.id}/attachment`); + if (!res.ok) { + return { + type: '', + url: '', + fileExists: false + }; + } const blob = await res.blob(); return { type: blob.type, url: URL.createObjectURL(blob), fileExists: res.ok }; + } catch (error) { + console.error('Failed to fetch attachment:', error); + return { + type: '', + url: '', + fileExists: false + }; + } };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
backend/core/models.py
(1 hunks)backend/core/views.py
(1 hunks)frontend/src/lib/components/ModelTable/EvidenceFilePreview.svelte
(2 hunks)frontend/src/routes/(app)/(third-party)/evidences/[id=uuid]/+page.svelte
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- frontend/src/lib/components/ModelTable/EvidenceFilePreview.svelte
- backend/core/views.py
- backend/core/models.py
🔇 Additional comments (2)
frontend/src/routes/(app)/(third-party)/evidences/[id=uuid]/+page.svelte (2)
19-23
: LGTM! Interface update aligns with PR objective.The addition of the
fileExists
boolean property to theAttachment
interface is a good approach to track attachment availability.
189-195
: LGTM! Clear user feedback for missing attachments.The conditional rendering provides appropriate feedback to users when attachments are missing, using localized messages.
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.
LGTM. Merging.
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.
LGTM
avoid crashing when the attachment is brutally removed from /db/attachments/
Summary by CodeRabbit
Release Notes
Bug Fixes
New Features
The changes focus on improving the reliability and user experience when working with file attachments across the application.