Skip to content

fix: Prevent endless polling on invalid file upload in Slack Users CSV importer#38548

Open
KumarHarshit3603 wants to merge 9 commits into
RocketChat:developfrom
KumarHarshit3603:api-fix
Open

fix: Prevent endless polling on invalid file upload in Slack Users CSV importer#38548
KumarHarshit3603 wants to merge 9 commits into
RocketChat:developfrom
KumarHarshit3603:api-fix

Conversation

@KumarHarshit3603
Copy link
Copy Markdown

@KumarHarshit3603 KumarHarshit3603 commented Feb 8, 2026

fix: Prevent endless polling on invalid file upload in Slack Users CSV importer

Summary(proposed changes)

This PR fixes an infinite polling loop that occurs when a user uploads an invalid file while trying to import a Slack Users CSV.

Before this change:

  • User selects "Slack Users CSV" import type
  • Uploads wrong file .
  • Backend parsing fails → import status becomes ERROR
  • Frontend keeps polling getImportFileData every ~1s forever
  • Network tab shows endless {"waiting":true,"success":true} responses
  • UI appears stuck / blocked

After this change:

  • Backend sets ProgressStep.ERROR immediately on parsing failure
  • getImportFileData endpoint early-exits and throws when status is already ERROR
  • Frontend checks error states before starting/continuing file polling
  • On error detection → immediately shows error message and navigates back
  • Polling stops after 2–3 requests maximum
Screenshot (5)

Result:
No more infinite network requests for invalid files
Legitimate large CSV files still have enough time to process (30–60s timeout preserved)

Issue(s)

Closes #38499

Steps to test or reproduce

  1. Go to Administration → Workspace → Import
  2. Click Import new file
  3. Select import type: Slack Users CSV
  4. Choose Upload and select a PDF file (or any non-CSV)
  5. Click Import
  6. Open browser Network tab → filter by getImportFileData
  7. Observe: only 2–3 requests are made → then polling stops
  8. UI should show an error message (e.g. "Invalid file format" or similar) and return to the import list

Compare with a valid CSV file:

  • Valid file → continues normal processing (more requests, progress updates)
  • Invalid file → quick failure, no infinite loop

Further comments

Backend changes summary

  • SlackUsersImporter.ts

    • Wrapped CSV parsing in try/catch
    • On parse failure → set ProgressStep.ERROR immediately + log error
  • getImportFileData.ts

    • Added early return / error throw when current import status is already ERROR
    • Prevents frontend from receiving misleading {"waiting":true} responses forever

Frontend changes summary

  • PrepareImportPage.tsx
    • Reordered logic: check error states before attempting to load file data
    • When error detected → stop polling, show message, navigate back
    • Result: polling loop terminates in ~1–2 seconds for bad files

The fix maintains good UX for valid imports while cleanly failing fast on invalid ones.

Thanks for reviewing!

Summary by CodeRabbit

  • New Features
    • Client-side file type validation for import uploads with visible error callouts, cleared invalid selections, and a disabled Import button when validation fails.
  • Bug Fixes
    • Import processing now logs failures and marks progress as Error to halt processing.
    • Import polling now has a capped retry mechanism to fail quickly on stuck imports.
  • Behavior
    • Ready imports in an ERROR step now surface an "invalid import-file-format" error.

@KumarHarshit3603 KumarHarshit3603 requested a review from a team as a code owner February 8, 2026 01:24
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 8, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 8, 2026

⚠️ No Changeset found

Latest commit: 89f7045

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 8, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

Adds client-side file-type validation to block wrong uploads, wraps server CSV parsing in a try-catch to set progress to ERROR on exceptions, and bounds the poller with a capped retry mechanism to prevent infinite getImportFileData calls.

Changes

Cohort / File(s) Summary
Client: File upload UI & validation
apps/meteor/client/views/admin/import/NewImportPage.tsx
Adds fileValidationError state and reset, getAllowedFileTypes and validateFile helpers, validates selected files on change, shows a danger Callout for invalid files, clears invalid selections, and disables the Import button when validation fails.
Client: Polling retry limit
apps/meteor/client/views/admin/import/PrepareImportPage.tsx
Introduces a capped retry mechanism in waitFor: retryCount with maxRetries (60); rejects when retryCount >= maxRetries; retries every 1s.
Server: CSV parsing error handling
apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
Wraps CSV parsing and user-creation in prepare() with try-catch; on exception logs error, sets progress to ProgressStep.ERROR, updates progress, and returns current progress.
Server: Import data retrieval error propagation
apps/meteor/app/importer/server/methods/getImportFileData.ts
When importer is ready but progress step is ERROR, throws Meteor.Error('error-import-file-format-invalid') instead of returning selection data, causing callers (poller) to stop further requests.

Sequence Diagram

sequenceDiagram
    participant Client as NewImportPage
    participant Server as getImportFileData
    participant Parser as SlackUsersImporter
    participant Poller as PrepareImportPage

    rect rgba(200,150,100,0.5)
    Note over Client: File selection & validation
    Client->>Client: validateFile(file, importerKey)
    alt validation fails
        Client->>Client: setFileValidationError()\nclear files\ndisable Import button
    else validation passes
        Client->>Server: upload/submit file
    end
    end

    rect rgba(100,150,200,0.5)
    Note over Server,Parser: Server-side parsing with error handling
    Server->>Parser: start CSV parsing
    alt parse error
        Parser->>Parser: catch(error)
        Parser->>Server: updateProgress(ERROR)
        Parser->>Server: return progress(ERROR)
    else parse success
        Parser->>Server: return progress(success)
    end
    end

    rect rgba(150,100,200,0.5)
    Note over Poller,Server: Polling with retry limit
    Poller->>Server: getImportFileData()
    alt response indicates ERROR
        Server->>Poller: throw Meteor.Error("error-import-file-format-invalid")
        Poller->>Poller: handle error / stop polling
    else response not final
        Poller->>Poller: increment retryCount\nif retryCount >= maxRetries -> reject
        Poller->>Server: wait 1s and retry
    else final progress
        Poller->>Poller: resolve()
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I sniff each file with a careful hop,
A wrong PDF — I catch and stop,
I log the parse and mark the stage,
I bound the polls to end the rage,
One tidy import — happy hop! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: preventing endless polling when an invalid file is uploaded to the Slack Users CSV importer.
Linked Issues check ✅ Passed All code changes directly address the linked issue #38499 objectives: backend error handling prevents misleading responses, frontend validation catches invalid files early, and retry limits prevent infinite polling.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the infinite polling issue: SlackUsersImporter adds error handling, getImportFileData throws on errors, NewImportPage adds client-side validation, and PrepareImportPage adds retry limits.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Copy link
Copy Markdown
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: 2

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/admin/import/NewImportPage.tsx`:
- Line 252: isImportDisabled can become a string because fileValidationError may
be a non-empty string and the || chain short-circuits; change the expression so
it always yields a boolean by coercing fileValidationError (or the whole
sub-expression) to a boolean. Update the isImportDisabled assignment
(referencing isImportDisabled, isLoading, importer, fileType,
fileValidationError, files) to use explicit boolean coercion, e.g. use
!!fileValidationError or Boolean(...) around the upload-specific checks so
disabled always receives a true/false value.
- Around line 140-144: The current error message in NewImportPage mixes a
translated string with hardcoded English (t('Invalid_Import_File_Type') + ':
Expected ' + allowedTypes.join(', ')); replace this with a single parameterized
translation key (e.g., "Invalid_Import_File_Type_Expected") and pass the allowed
types as a placeholder when calling t; update the call in the invalidFiles
branch that uses getAllowedFileTypes(importerKey) and
setFileValidationError(...) to call t('Invalid_Import_File_Type_Expected', {
types: allowedTypes.join(', ') }), and add the new translation key ("Invalid
Import file type: Expected {{types}}") to the project translation files for each
locale.
🧹 Nitpick comments (6)
apps/meteor/app/importer/server/methods/getImportFileData.ts (1)

53-56: Remove the code comment.

As per coding guidelines, code comments should be avoided in the implementation.

Proposed fix
 	if (readySteps.indexOf(instance.progress.step) >= 0) {
-		// If import failed/errored, throw error instead of trying to build selection
 		if (instance.progress.step === ProgressStep.ERROR) {
 			throw new Meteor.Error('error-import-file-format-invalid', 'Failed to process import file. Please check the file format and try again.', 'getImportFileData');
 		}

As per coding guidelines: **/*.{ts,tsx,js}: Avoid code comments in the implementation.

apps/meteor/client/views/admin/import/PrepareImportPage.tsx (3)

27-31: Remove code comments from implementation.

Lines 28, 39-40, and 51 contain explanatory comments. Per coding guidelines, these should be removed.

As per coding guidelines: **/*.{ts,tsx,js}: Avoid code comments in the implementation.


34-43: Stall detection condition is largely redundant with maxRetries.

Both maxRetries (300 × 1s = 5 min) and the stall check (2 min + 120 identical responses ≈ 2 min) serve as upper bounds. The stall check will always fire before maxRetries if the response is stuck, making maxRetries only relevant if responses keep changing without reaching the predicate. This is fine as defense-in-depth, but worth noting for maintainability.


52-52: JSON.stringify comparison on every poll iteration.

This works for the small response objects returned by getImportFileData but is worth noting as a potential concern if response payloads grow. A shallow key comparison or status-field check would be more efficient and explicit.

apps/meteor/client/views/admin/import/NewImportPage.tsx (2)

91-107: Extract getAllowedFileTypes outside the component.

This pure function doesn't depend on component state or props (it receives importerKeyParam as argument). Defining it inside the component recreates it on every render. Move it to module scope.

Proposed fix
+const getAllowedFileTypes = (importerKeyParam: string | undefined): string[] => {
+	if (!importerKeyParam) return [];
+	if (importerKeyParam === 'csv' || importerKeyParam === 'slack-users') return ['text/csv', '.csv', 'text/plain'];
+	if (importerKeyParam === 'slack' || importerKeyParam === 'hipchat') return ['application/zip', '.zip'];
+	return [];
+};
+
 function NewImportPage() {

326-330: Remove code comments from implementation.

Multiple lines in this file contain explanatory comments (lines 90, 96, 101, 116, 137). Per coding guidelines, these should be removed.

As per coding guidelines: **/*.{ts,tsx,js}: Avoid code comments in the implementation.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb366e7 and 0957505.

📒 Files selected for processing (4)
  • apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
  • apps/meteor/app/importer/server/methods/getImportFileData.ts
  • apps/meteor/client/views/admin/import/NewImportPage.tsx
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/importer/server/methods/getImportFileData.ts
  • apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
  • apps/meteor/client/views/admin/import/NewImportPage.tsx
🧠 Learnings (5)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
⏰ 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: cubic · AI code reviewer
🔇 Additional comments (2)
apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts (1)

44-110: LGTM — try-catch properly prevents unhandled parse errors.

The error handling correctly catches CSV parse failures, logs the error, and transitions to the ERROR state, which aligns with the server-side changes in getImportFileData.ts.

apps/meteor/client/views/admin/import/NewImportPage.tsx (1)

91-107: Hardcoded importer-to-file-type mapping requires manual maintenance.

The mapping at lines 91-107 is currently necessary since server-side importer definitions do not expose file type information. Neither the ImporterInfo type nor the /v1/importers.list endpoint includes MIME type or file extension metadata. If new importers are added or existing ones change their expected file formats, this mapping must be updated manually. Consider extending the ImporterInfo type to include an optional allowedFileTypes field that importers can declare, which could then be returned by /v1/importers.list to eliminate the need for client-side hardcoding.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread apps/meteor/client/views/admin/import/NewImportPage.tsx
Comment thread apps/meteor/client/views/admin/import/NewImportPage.tsx Outdated
Copy link
Copy Markdown
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: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/admin/import/PrepareImportPage.tsx`:
- Around line 28-42: The stall-detection branch in callPromise is unreachable
because retryCount (checked against maxRetries = 60) will always hit before
sameResponseCount (>120); remove the dead stall block that checks Date.now() -
lastProgressTime and sameResponseCount, or if stall detection is desired, adjust
thresholds so they’re consistent (e.g., set maxRetries > 120 or reduce the
sameResponseCount threshold under maxRetries); update the logic around
maxRetries, sameResponseCount, lastProgressTime and callPromise to use the
chosen approach and ensure retryCount and sameResponseCount are
incremented/checked consistently.
🧹 Nitpick comments (1)
apps/meteor/client/views/admin/import/PrepareImportPage.tsx (1)

50-51: Remove the code comment.

As per coding guidelines, avoid code comments in TypeScript/JavaScript implementation files.

-			// Track if we're making progress or stuck in loop
-			if (lastResponse && JSON.stringify(result) === JSON.stringify(lastResponse)) {
+			if (lastResponse && JSON.stringify(result) === JSON.stringify(lastResponse)) {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0957505 and fe22f54.

📒 Files selected for processing (1)
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🧠 Learnings (4)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
⏰ 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: cubic · AI code reviewer
🔇 Additional comments (1)
apps/meteor/client/views/admin/import/PrepareImportPage.tsx (1)

104-178: Effect logic for error-state detection looks correct.

The loadCurrentOperation function properly checks ImportingErrorStates (line 158) and navigates back, and the waitFor rejection in loadImportFileData (line 124) is caught and handled. With the backend changes (throwing Meteor.Error when progress is ERROR), the waitFor call will reject quickly, which is the desired behavior for invalid uploads.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread apps/meteor/client/views/admin/import/PrepareImportPage.tsx Outdated
Copy link
Copy Markdown
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: 1

🤖 Fix all issues with AI agents
In `@apps/meteor/client/views/admin/import/NewImportPage.tsx`:
- Line 88: The fileValidationError state (declared via useState as
fileValidationError / setFileValidationError) must be cleared when the importer
changes; update handleImporterKeyChange (or add a useEffect watching
importerKey) to call setFileValidationError('') whenever the selected importer
key changes so stale validation errors are removed when switching importers.
🧹 Nitpick comments (4)
apps/meteor/app/importer/server/methods/getImportFileData.ts (1)

53-56: Remove the implementation comment.

As per coding guidelines, **/*.{ts,tsx,js} files should avoid code comments in the implementation. The intent is already clear from the code structure.

Proposed fix
 	if (readySteps.indexOf(instance.progress.step) >= 0) {
-		// If import failed/errored, throw error instead of trying to build selection
 		if (instance.progress.step === ProgressStep.ERROR) {
 			throw new Meteor.Error('error-import-file-format-invalid', 'Failed to process import file. Please check the file format and try again.', 'getImportFileData');
 		}
 		return instance.buildSelection();
 	}
apps/meteor/client/views/admin/import/PrepareImportPage.tsx (1)

50-56: Remove implementation comments.

Lines 50 has a comment that violates the coding guideline for **/*.{ts,tsx,js} files. As per coding guidelines, avoid code comments in the implementation.

Proposed fix
-			// Track if we're making progress or stuck in loop
 			if (lastResponse && JSON.stringify(result) === JSON.stringify(lastResponse)) {
apps/meteor/client/views/admin/import/NewImportPage.tsx (2)

90-107: Remove implementation comments and extract helpers outside the component.

Multiple comments in these functions violate the coding guideline for **/*.{ts,tsx,js} files. Also, getAllowedFileTypes and validateFile are pure functions that don't depend on component state — they should be extracted outside the component to avoid recreation on every render.

Proposed refactor

Move these before the component definition:

+const allowedFileTypesByImporter: Record<string, string[]> = {
+	csv: ['text/csv', '.csv', 'text/plain'],
+	'slack-users': ['text/csv', '.csv', 'text/plain'],
+	slack: ['application/zip', '.zip'],
+	hipchat: ['application/zip', '.zip'],
+};
+
+const getAllowedFileTypes = (importerKeyParam: string | undefined): string[] =>
+	(importerKeyParam && allowedFileTypesByImporter[importerKeyParam]) || [];
+
+const validateFile = (file: File, importerKeyParam: string | undefined): boolean => {
+	const allowedTypes = getAllowedFileTypes(importerKeyParam);
+	if (allowedTypes.length === 0) return true;
+	const fileExtension = `.${file.name.split('.').pop()?.toLowerCase()}`;
+	return allowedTypes.includes(file.type) || allowedTypes.includes(fileExtension);
+};
+
 function NewImportPage() {

And remove lines 91–122 from inside the component.


135-148: Remove implementation comments.

Line 137 (// Validate all files) violates the coding guideline for **/*.{ts,tsx,js} files. As per coding guidelines, avoid code comments in the implementation.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe22f54 and 35f6d65.

📒 Files selected for processing (4)
  • apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
  • apps/meteor/app/importer/server/methods/getImportFileData.ts
  • apps/meteor/client/views/admin/import/NewImportPage.tsx
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/importer/server/methods/getImportFileData.ts
  • apps/meteor/client/views/admin/import/NewImportPage.tsx
  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
🧠 Learnings (7)
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • apps/meteor/client/views/admin/import/NewImportPage.tsx
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.

Applied to files:

  • apps/meteor/client/views/admin/import/NewImportPage.tsx
📚 Learning: 2025-10-06T20:32:23.658Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37152
File: packages/apps-engine/tests/test-data/utilities.ts:557-573
Timestamp: 2025-10-06T20:32:23.658Z
Learning: In packages/apps-engine/tests/test-data/utilities.ts, the field name `isSubscripbedViaBundle` in the `IMarketplaceSubscriptionInfo` type should not be flagged as a typo, as it may match the upstream API's field name.

Applied to files:

  • apps/meteor/client/views/admin/import/NewImportPage.tsx
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/client/views/admin/import/NewImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/client/views/admin/import/PrepareImportPage.tsx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread apps/meteor/client/views/admin/import/NewImportPage.tsx
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/meteor/client/views/admin/import/NewImportPage.tsx">

<violation number="1" location="apps/meteor/client/views/admin/import/NewImportPage.tsx:147">
P3: Hardcoded English concatenation in a user-facing error message breaks i18n and will show untranslated text for non-English locales.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


if (invalidFiles.length > 0) {
const allowedTypes = getAllowedFileTypes(importerKey);
setFileValidationError(t('Invalid_Import_File_Type') + ': Expected ' + allowedTypes.join(', '));
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Feb 8, 2026

Choose a reason for hiding this comment

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

P3: Hardcoded English concatenation in a user-facing error message breaks i18n and will show untranslated text for non-English locales.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/admin/import/NewImportPage.tsx, line 147:

<comment>Hardcoded English concatenation in a user-facing error message breaks i18n and will show untranslated text for non-English locales.</comment>

<file context>
@@ -144,7 +144,7 @@ function NewImportPage() {
 		if (invalidFiles.length > 0) {
 			const allowedTypes = getAllowedFileTypes(importerKey);
-			setFileValidationError(t('Invalid_Import_File_Type_Expected', { types: allowedTypes.join(', ') }));
+			setFileValidationError(t('Invalid_Import_File_Type') + ': Expected ' + allowedTypes.join(', '));
 			setFiles([]);
 			return;
</file context>
Fix with Cubic

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.

Infinity api call due to importing of wrong file

2 participants