Skip to content

Conversation

@rahul1841
Copy link
Contributor

@rahul1841 rahul1841 commented Oct 3, 2025

Description

  • removed unsupported files while sending to server

Testing

  • tested locally

Summary by CodeRabbit

  • Bug Fixes
    • Uploads now automatically skip unsupported files instead of failing the entire process.
    • Clear error message shown when no valid files remain to upload.
    • Validation consistently applied across main upload and “add files to collection” flows.
    • Batching, progress, and upload initiation now operate only on valid files, reducing failed attempts.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rahul1841, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the knowledge management file upload functionality by introducing a pre-upload validation step. It ensures that only supported file types are processed for upload, preventing potential issues with unsupported files being sent to the server. The change also improves the user experience by providing immediate feedback if a user attempts to upload only unsupported files.

Highlights

  • File Validation: Implemented client-side validation to filter out unsupported files before they are sent to the server for upload in the knowledge management feature.
  • User Feedback: Added a toast notification that informs the user if all selected files are unsupported, preventing an empty upload and providing clear feedback.
  • Utility Integration: Integrated the isValidFile utility function from shared/fileUtils to perform the necessary file type checks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds pre-upload validation using isValidFile to filter selected files in both upload entry points; aborts with an error toast when no valid files remain and ensures batching and startUpload operate only on validated files. Imports isValidFile from shared utilities.

Changes

Cohort / File(s) Summary
Upload validation and flow refinement
frontend/src/routes/_authenticated/knowledgeManagement.tsx
Add isValidFile import; introduce getValidFilesOrShowError to filter input files and show an error toast when none are valid; switch both upload entry points to build batches and file mappings from validFiles; early-return when no valid files; call startUpload with valid-derived batches/files.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant KM as KnowledgeManagement UI
  participant FU as fileUtils.isValidFile
  participant UP as Upload Service
  participant T as Toast

  U->>KM: Select files and initiate upload
  KM->>FU: Filter files (isValidFile)
  alt No valid files
    KM->>T: Show error toast
    note over KM,T: Abort upload
  else Valid files exist
    KM->>KM: Create batches from validFiles
    KM->>UP: startUpload(batches from validFiles)
    UP-->>KM: Upload results (success/failure)
    KM->>T: Show success/error toasts
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • shivamashtikar
  • junaid-shirur
  • kalpadhwaryu
  • devesh-juspay
  • zereraz

Poem

I hopped through folders, checking each name,
Tossed the bad ones, then called the same game.
Batches tidy, uploads start with a cheer,
If none pass muster, a toast will appear.
A rabbit nods—valid files, let’s steer! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarizes the primary change by indicating that unsupported files are removed before being sent to the server, matching the changeset’s focus on filtering valid files during the upload flow.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/UnsupportedFileFix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12d736e and 68ba2c5.

📒 Files selected for processing (1)
  • frontend/src/routes/_authenticated/knowledgeManagement.tsx (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/routes/_authenticated/knowledgeManagement.tsx (1)
server/shared/fileUtils.ts (1)
  • isValidFile (10-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (4)
frontend/src/routes/_authenticated/knowledgeManagement.tsx (4)

40-40: LGTM!

The import statement correctly brings in the isValidFile utility from the shared module for file validation.


644-657: LGTM!

The utility function correctly filters valid files and provides clear user feedback when no valid files are selected. The early return pattern with null is appropriate for error handling.


681-687: LGTM!

The validation logic is correctly integrated into the upload flow. Using validFiles for batching and file mapping ensures only supported files are processed, preventing server-side errors.


881-887: LGTM!

The validation is consistently applied in this upload entry point, matching the pattern used in handleUpload. This ensures uniform behavior across both new collection creation and adding files to existing collections.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses the issue of uploading unsupported files to the server by adding a validation step that filters out invalid files before initiating the upload process. This change enhances the user experience by providing immediate feedback when unsupported files are selected and prevents unnecessary server requests. The code changes include importing the isValidFile function, filtering the selected files, displaying an error toast if no valid files are selected, and modifying the createBatches and startUpload functions to use the filtered list of valid files.

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

🧹 Nitpick comments (1)
frontend/src/routes/_authenticated/knowledgeManagement.tsx (1)

666-676: Consider notifying users about partially filtered files.

The current implementation only shows an error when all selected files are unsupported. If a user selects 10 files and 3 are unsupported, those 3 are silently filtered out. Consider enhancing the UX by showing a warning toast that lists which specific files were excluded, so users understand what was filtered and why.

Example enhancement:

 // Filter out unsupported files before upload
 const validFiles = selectedFiles.filter(f => isValidFile(f.file))
+const invalidFiles = selectedFiles.filter(f => !isValidFile(f.file))

+if (invalidFiles.length > 0 && validFiles.length > 0) {
+  toast.warning({
+    title: "Some files excluded",
+    description: `${invalidFiles.length} unsupported file${invalidFiles.length !== 1 ? 's' : ''} excluded from upload.`,
+  })
+}

 if (validFiles.length === 0) {
   toast.error({
     title: "Upload Error",
     description: "No valid files to upload. All selected files are unsupported.",
   })
   return
 }

Also applies to: 874-883

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0e79f8 and 12d736e.

📒 Files selected for processing (1)
  • frontend/src/routes/_authenticated/knowledgeManagement.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/routes/_authenticated/knowledgeManagement.tsx (1)
server/shared/fileUtils.ts (1)
  • isValidFile (10-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (5)
frontend/src/routes/_authenticated/knowledgeManagement.tsx (5)

40-40: LGTM! Import is correctly added.

The import of isValidFile from the shared utilities aligns with the monorepo structure and provides centralized file validation logic.


666-676: LGTM! Validation logic is correct.

The pre-upload validation properly filters unsupported files and provides clear user feedback when no valid files remain. The early return prevents unnecessary processing.


679-680: LGTM! Batching correctly uses filtered files.

The batching logic properly operates on validFiles, ensuring only supported files are processed and uploaded. This maintains data consistency throughout the upload flow.


874-883: LGTM! Consistent validation in add-to-collection flow.

The validation logic mirrors the main upload flow, ensuring consistent behavior across both entry points. The error handling is appropriate and user-friendly.


886-887: LGTM! Add-to-collection batching is correct.

The batching logic is consistent with the main upload flow, using validFiles to ensure only supported files are processed.

@shivamashtikar shivamashtikar merged commit cb2c423 into main Oct 4, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants