Skip to content
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

Get error for specific inputs when updated #10446

Merged

Conversation

DonXavierdev
Copy link
Contributor

@DonXavierdev DonXavierdev commented Feb 6, 2025

Proposed Changes

@nihal467

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • Bug Fixes
    • Revised the file upload error detection so that missing file names now trigger warnings for any affected file, rather than just the first one. This adjustment ensures that users receive clear, comprehensive feedback during the upload process, helping to prevent confusion and improve the overall experience.

@DonXavierdev DonXavierdev requested a review from a team as a code owner February 6, 2025 10:03
Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 97dbc77
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67a489c01d1a9c00083980f6
😎 Deploy Preview https://deploy-preview-10446--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

The pull request modifies the error handling within the FileUploadDialog component in the src/components/Files/FilesTab.tsx file. It changes the logic so that instead of showing an error only for the first file (based on an index check), it now displays an error for any file missing a name. This ensures that in multi-file uploads, every file lacking a name will trigger an error message.

Changes

File(s) Change Summary
src/.../FilesTab.tsx Updated conditional rendering in FileUploadDialog: now checks for missing file names instead of using an index check (index === 0)

Assessment against linked issues

Objective Addressed Explanation
Enable PDF file uploads in file module (#10443) The changes focus solely on error messaging; PDF upload logic is absent.
Disable upload button if a file name is not provided & ensure all files have names (#10443) Only the error message display was adjusted; button disable logic remains unchanged.

Possibly related PRs

Suggested labels

needs review, changes required

Suggested reviewers

  • Jacobjeevan
  • rithviknishad

Poem

I'm a little rabbit, quick on my feet,
Hopping through code where errors and fixes meet.
Missing file names now get caught in the act,
A tweak in logic, and nothing is slack!
Cheers to neat code and a hop-filled track!
🐇🌟

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🔭 Outside diff range comments (2)
src/components/Files/FilesTab.tsx (2)

713-726:

🧩 Analysis chain

Verify PDF combination functionality.

The code allows combining multiple files into a PDF, but there's no validation to ensure all selected files are compatible with PDF conversion.

Let's check if there are any file type validations for PDF combination:


🏁 Script executed:

#!/bin/bash
# Search for PDF-related validations
rg -A 5 "pdf|combine.*files"

Length of output: 12720


PDF Conversion Validation Issue

The current implementation of PDF combination in useFileUpload.tsx does not perform any validation on the file types before combining them. The generatePDF function assumes that each file is convertible via jsPDF.addImage (using a hard-coded "JPEG" type), which may lead to issues if non-image files are selected.

  • Location: src/hooks/useFileUpload.tsx (no file type validation prior to PDF conversion)

131-155:

🧩 Analysis chain

Consider security implications of allowed file extensions.

The list of allowed file extensions includes potentially risky file types that could be used for malicious purposes (e.g., .doc, .xls). Consider:

  1. Implementing additional security checks for these file types
  2. Adding virus scanning for uploaded files
  3. Limiting file extensions based on user roles

Let's check if there are any security measures in place:


🏁 Script executed:

#!/bin/bash
# Search for security-related code in file handling
rg -i "virus|malware|sanitize|security" 

Length of output: 727


Based on the global search results, there is no evidence that the file handling in FilesTab.tsx is applying any extra security measures—such as virus scanning or file content validation—beyond simply filtering by extension. This suggests the concerns in the review comment are valid. You might consider one or more of the following actions:

  • Implement additional file content verification (e.g. virus scanning) for uploaded files.
  • Introduce server‐side validation/sanitization of file contents based on file type.
  • Enforce file extension restrictions dynamically, possibly based on user roles.

These adjustments would help mitigate the potential risks associated with allowing file types like .doc, .xls, etc.

Recommended actions:

  • Add middleware or server-side hooks for virus scanning.
  • Extend file handling logic in FilesTab.tsx (or related backend code) with further security validations.
  • Review the allowed file extension policy to ensure it aligns with your application's security requirements.
🧹 Nitpick comments (2)
src/components/Files/FilesTab.tsx (2)

156-161: Consider enabling compression for image uploads.

The compress option is set to false in the file upload configuration. Enabling compression for image files could improve performance and reduce storage costs.

-    compress: false,
+    compress: true,
+    compressionOptions: {
+      maxSizeMB: 1,
+      maxWidthOrHeight: 1920,
+      useWebWorker: true
+    },

748-750: Consider adding upload speed information.

While the progress bar shows upload progress, it would be helpful to show upload speed and estimated time remaining for large files.

         {!!fileUpload.progress && (
-          <Progress value={fileUpload.progress} className="mt-4" />
+          <div className="mt-4">
+            <Progress value={fileUpload.progress} />
+            <div className="text-sm text-gray-500 mt-1">
+              {uploadSpeed} - {timeRemaining}
+            </div>
+          </div>
         )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85866da and 97dbc77.

📒 Files selected for processing (1)
  • src/components/Files/FilesTab.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (1)
src/components/Files/FilesTab.tsx (1)

703-707: Improved error handling for file name validation.

The change enhances error handling by showing the error message only when a specific file's name is missing, rather than showing it for all files. This provides better user feedback by pinpointing which file needs attention.

@nihal467
Copy link
Member

nihal467 commented Feb 6, 2025

LGTM

@amjithtitus09 amjithtitus09 merged commit 868ea1c into ohcnetwork:develop Feb 6, 2025
14 of 15 checks passed
Copy link

github-actions bot commented Feb 6, 2025

@DonXavierdev Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Additional Bugs in File upload
4 participants