Skip to content

TDH-3129-new Add configuration to allow certain extensions only#1440

Merged
kandpal025 merged 3 commits intodevelopmentfrom
TDH-3129-new
Jan 11, 2026
Merged

TDH-3129-new Add configuration to allow certain extensions only#1440
kandpal025 merged 3 commits intodevelopmentfrom
TDH-3129-new

Conversation

@AashishBhatt5
Copy link
Copy Markdown
Contributor

@AashishBhatt5 AashishBhatt5 commented Jan 9, 2026

What do you want to achieve?

PR Checklist

  • I have tested it locally and all functionalities are working fine.
  • I have compared it with mocks and all design elements are the same.
  • I have tested it in IE Browser.

How was the code tested?

What new thing you came across while writing this code?

In case you fixed a bug then please describe the root cause of it?

Screenshot

NOTE: Make sure you're comparing your branch with the correct base branch

Summary by CodeRabbit

  • Bug Fixes
    • Standardized user-facing error notification for blocked file types—replaces disruptive alerts with a consistent, non-intrusive message and stops further upload processing for those files.
    • Ensures progress indicators are cleared when a file type is rejected, improving clarity and preventing misleading upload status.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 9, 2026

Messages
📖 New Files in this PR: - 0
📖 Jira Issue Link - 🔗 TDH-3129

Generated by 🚫 dangerJS against 9f8afdb

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 9, 2026

Walkthrough

Centralized file-extension error handling in the upload flow by adding showFileExtensionError(errorMessage) to MckFileService and invoking it where server responses indicate FILE_TYPE_NOT_ALLOWED (including HTTP 403), with uploads returning early on that condition.

Changes

Cohort / File(s) Summary
File Upload Error Handling
webplugin/js/app/mck-sidebox-1.0.js
Added showFileExtensionError(errorMessage) to MckFileService; replaced inline alert() calls in uploadFile and uploadAttachment2AWS with this method; added early returns on server FILE_TYPE_NOT_ALLOWED / HTTP 403 responses; ensured progress UI is hidden and timeouts cleared to avoid overlapping messages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'TDH-3129-new Add configuration to allow certain extensions only' is partially related but misleading; actual changes add a new error notification function, not a configuration system. Revise the title to accurately reflect the main change, such as 'Centralize file extension validation error notifications' or 'Add showFileExtensionError method for consistent file type error handling'.
Description check ⚠️ Warning The PR description is entirely unfilled; all required sections contain only template placeholders with no actual implementation details, testing information, or design context provided. Fill in all sections of the PR template with specific details: what was achieved, how it was tested, testing results, and design/mock comparisons; check the PR checklist items once verified.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.

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

✨ Finishing touches
  • 📝 Generate docstrings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.1.2)
webplugin/js/app/mck-sidebox-1.0.js

The --json option is unstable/experimental and its output might change between patches/minor releases.
{"summary":{"changed":0,"unchanged":1,"matches":0,"duration":{"secs":9,"nanos":377598601},"scannerDuration":{"secs":0,"nanos":3479640},"errors":124,"warnings":0,"skipped":0,"suggestedFixesSkipped":0,"diagnosticsNotPrinted":0},"diagnostics":[{"category":"lint/correctness/noUnreachable","severity":"error","description":"This code is unreachable","message":[{"elements":[],"content":"This code is unreachable"}],"advices":{"advices":[]},"verboseAdvices":{"advices":[]},"location":{"path":{"file":"webplugin/js/app/mck-sidebox-1.0.js"},"span":[5164,5170],"sourceCode":"var MCK_GROUP_MAP = [];\nvar MCK_CLIENT_GROUP_MAP = [];\nvar MCK_EVENT_HISTORY = [];\nvar KM_PROGRESS_METER_RADIUS = 54;\nvar KM_PROGRESS_METER_CIRCUMFERENCE = 2 * Math.PI * KM_PROGRESS_METER_RADIUS;\nvar count = 0;\nvar isFirstLaunch = true;\nvar KM_PENDING_ATTACHMENT_FILE = new Map();\nvar MCK_TRIGGER_MSG_NOTIFICATION_PARAM;\n

... [truncated 99999690 characters] ...

$mck_tab_status.html(groupMembers);\n                    $mck_tab_status.attr('title', groupMembers);\n                    // kommunicateCommons.show('#mck-tab-status');\n      Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue.

When opening the issue, please provide a minimal reproduction, or identify and share the file/code that triggers it. Without a way to reproduce the error, the error can't be fixed:

Source Location: crates/biome_console/src/lib.rs:151:14
Thread Name: main
Message: called Result::unwrap() on an Err value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }


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

@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 (3)
webplugin/js/app/mck-sidebox-1.0.js (3)

13463-13478: Good centralized error display with timeout management.

The implementation correctly clears any pending timeout before setting a new one, preventing message overlap. The 5-second auto-hide provides good UX.

Note: AI summary incorrectly states the parameter is messageKey, but it's actually errorMessage (line 13463).

Minor consideration: If the containing component/service can be destroyed while a timeout is pending, consider adding cleanup logic to prevent memory leaks. However, given the isolated scope mentioned in learnings, this may not be a concern.


13878-13911: Error handling works but has maintainability concerns.

The logic correctly handles FILE_TYPE_NOT_ALLOWED errors with proper UI cleanup and message removal.

Code duplication: The error extraction logic (lines 13888-13894) is duplicated from lines 13718-13724 in hunk 4. Consider extracting this into a helper function:

♻️ Refactor to eliminate duplication
var extractFileTypeErrorMessage = function(responseJson) {
    return (responseJson.errorResponse &&
            responseJson.errorResponse[0] &&
            (responseJson.errorResponse[0].description ||
                responseJson.errorResponse[0].displayMessage)) ||
        (responseJson && responseJson.errorMessage) ||
        'File type is not allowed.';
};

Then replace the duplicated code with:

- var errorMsg =
-     (responseJson.errorResponse &&
-         responseJson.errorResponse[0] &&
-         (responseJson.errorResponse[0].description ||
-             responseJson.errorResponse[0].displayMessage)) ||
-     (responseJson && responseJson.errorMessage) ||
-     'File type is not allowed.';
+ var errorMsg = extractFileTypeErrorMessage(responseJson);

Naming clarity: Lines 13895 and 13897 call two different functions both named showFileExtensionError:

  • Line 13895: local function that displays error message to user
  • Line 13897: _this.showFileExtensionError(messagePxy.key) which resets UI state (defined in hunk 6)

While both calls appear intentional, the identical naming is confusing. Consider renaming the service method to something like resetFileUploadUI for clarity.


14156-14161: Function naming creates confusion.

The logic correctly resets the UI state for a message by showing the upload icon, hiding the cancel icon and progress bar.

Critical naming issue: This method _this.showFileExtensionError(messageKey) has the same name as the local function at line 13463, but serves a completely different purpose:

  • Local function (line 13463): Displays an error message string to the user with a 5-second timeout
  • Service method (line 14156): Resets UI state (shows/hides icons) for a specific message key

This creates significant confusion, especially evident in hunk 5 where both are called sequentially (lines 13895, 13897).

Recommendation: Rename this service method to reflect its actual purpose:

♻️ Suggested rename
- _this.showFileExtensionError = function (messageKey) {
+ _this.resetFileUploadUI = function (messageKey) {
     kommunicateCommons.show('.km-attachment-upload-icon-' + messageKey);
     kommunicateCommons.hide('.km-attachment-cancel-icon-' + messageKey);
     kommunicateCommons.show('.mck-timestamp-' + messageKey);
     kommunicateCommons.hide('.km-attachment-progress-bar-wrapper-' + messageKey);
 };

Then update the call site at line 13897:

- _this.showFileExtensionError(messagePxy.key);
+ _this.resetFileUploadUI(messagePxy.key);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be5f79a and 6bfe291.

📒 Files selected for processing (1)
  • webplugin/js/app/mck-sidebox-1.0.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-25T05:44:56.580Z
Learnt from: panwaranuj01
Repo: Kommunicate-io/Kommunicate-Web-SDK PR: 1320
File: webplugin/js/app/voice/mck-voice.js:758-758
Timestamp: 2025-06-25T05:44:56.580Z
Learning: The code in webplugin/js/app/voice/mck-voice.js runs in an isolated scope and does not pollute the global namespace of other windows or the host page. Global variables within this isolated scope are acceptable as they don't affect the embedding environment.

Applied to files:

  • webplugin/js/app/mck-sidebox-1.0.js
⏰ 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: Seer Code Review
🔇 Additional comments (3)
webplugin/js/app/mck-sidebox-1.0.js (3)

13448-13448: LGTM - Error element reference added.

The $mck_msg_error variable is correctly initialized and will be used by the new error handling function.


13651-13658: LGTM - Consistent error handling added.

The code properly displays upload errors using the centralized error function and cleans up failed messages from the UI.


13708-13730: Robust error handling for blocked file types.

The implementation correctly:

  • Handles multiple response formats (errorResponse array and direct errorCode)
  • Extracts error messages with a sensible fallback chain
  • Performs UI cleanup (re-enables buttons, triggers file removal)
  • Returns early to prevent further processing

Observation: This handler only calls the local showFileExtensionError(errorMsg) function, whereas hunk 5 (lines 13895-13897) calls both the local function and _this.showFileExtensionError(messagePxy.key). Verify this difference is intentional based on the upload context.

Comment on lines +13652 to +13657
if (messagePxy) {
mckMessageLayout.removedDeletedMessage(
messagePxy.key,
messagePxy.groupId,
true
);

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The code is correct for its intended use case. The if (messagePxy) check is appropriate because cleanup is only needed when a message was actually created. No fix needed unless you're seeing actual orphaned UI elements in production.

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
return;
}
if (
(responseJson &&
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

duplicate code checks

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: 0

🧹 Nitpick comments (2)
webplugin/js/app/mck-sidebox-1.0.js (2)

13889-13891: Confusing naming: local function and instance method share the same name but have different purposes.

Line 13889 calls the local showFileExtensionError(errorMsg) which displays an error message, while line 13891 calls _this.showFileExtensionError(messagePxy.key) which updates UI elements (icons, progress bars). This is confusing and error-prone.

Consider renaming one of them:

  • Rename the local function to displayFileExtensionErrorMessage(errorMessage)
  • Or rename the instance method to resetAttachmentUIOnError(messageKey) or similar

13882-13888: Duplicate error message extraction logic.

This error message extraction logic is identical to lines 13715-13721 in the uploadFile handler. Consider extracting into a helper function.

♻️ Proposed refactor

Add a helper function near the top of the file service:

var extractFileErrorMessage = function (responseJson) {
    return (responseJson.errorResponse &&
            responseJson.errorResponse[0] &&
            (responseJson.errorResponse[0].description ||
                responseJson.errorResponse[0].displayMessage)) ||
        (responseJson && responseJson.errorMessage) ||
        'File type is not allowed.';
};

Then use it in both handlers:

-var errorMsg =
-    (responseJson.errorResponse &&
-        responseJson.errorResponse[0] &&
-        (responseJson.errorResponse[0].description ||
-            responseJson.errorResponse[0].displayMessage)) ||
-    (responseJson && responseJson.errorMessage) ||
-    'File type is not allowed.';
+var errorMsg = extractFileErrorMessage(responseJson);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfe291 and 39bf657.

📒 Files selected for processing (1)
  • webplugin/js/app/mck-sidebox-1.0.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-25T05:44:56.580Z
Learnt from: panwaranuj01
Repo: Kommunicate-io/Kommunicate-Web-SDK PR: 1320
File: webplugin/js/app/voice/mck-voice.js:758-758
Timestamp: 2025-06-25T05:44:56.580Z
Learning: The code in webplugin/js/app/voice/mck-voice.js runs in an isolated scope and does not pollute the global namespace of other windows or the host page. Global variables within this isolated scope are acceptable as they don't affect the embedding environment.

Applied to files:

  • webplugin/js/app/mck-sidebox-1.0.js
⏰ 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: Seer Code Review
🔇 Additional comments (4)
webplugin/js/app/mck-sidebox-1.0.js (4)

13462-13478: LGTM!

The timeout management is properly implemented - clearing any existing timeout before setting a new one prevents stacking/duplicate hide operations.


13648-13659: LGTM!

Error display and message cleanup are handled correctly.


13708-13727: LGTM!

The 403 error handling correctly extracts the error message with appropriate fallbacks and properly cleans up the UI state.


14150-14155: LGTM!

The method follows the existing pattern (similar to showMaliciousFileError) and correctly resets the attachment UI state. As noted earlier, consider a more distinct name to avoid confusion with the local showFileExtensionError function.

Comment thread webplugin/js/app/mck-sidebox-1.0.js Outdated
return;
}
if (
this.status === 403 &&
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

still duplicate checks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can you check now ?

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: 0

🧹 Nitpick comments (1)
webplugin/js/app/mck-sidebox-1.0.js (1)

13480-13526: Consider consolidating the duplicate messagePxy checks.

The function handles error cleanup well, but there are two separate if (messagePxy) blocks (lines 13503-13505 and 13516-13522) that could be consolidated into a single block for clarity.

♻️ Suggested consolidation
                     showFileExtensionError(errorMsg);
-                    if (messagePxy) {
-                        _this.showFileExtensionError(messagePxy.key);
-                    }
                     if ($file_remove) {
                         $file_remove.attr('disabled', false);
                         $file_remove.trigger('click');
                     }
                     if ($mck_file_upload) {
                         $mck_file_upload.attr('disabled', false);
                     }
                     if ($mck_msg_sbmt) {
                         $mck_msg_sbmt.attr('disabled', false);
                     }
                     if (messagePxy) {
+                        _this.showFileExtensionError(messagePxy.key);
                         mckMessageLayout.removedDeletedMessage(
                             messagePxy.key,
                             messagePxy.groupId,
                             true
                         );
                     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39bf657 and 9f8afdb.

📒 Files selected for processing (1)
  • webplugin/js/app/mck-sidebox-1.0.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-25T05:44:56.580Z
Learnt from: panwaranuj01
Repo: Kommunicate-io/Kommunicate-Web-SDK PR: 1320
File: webplugin/js/app/voice/mck-voice.js:758-758
Timestamp: 2025-06-25T05:44:56.580Z
Learning: The code in webplugin/js/app/voice/mck-voice.js runs in an isolated scope and does not pollute the global namespace of other windows or the host page. Global variables within this isolated scope are acceptable as they don't affect the embedding environment.

Applied to files:

  • webplugin/js/app/mck-sidebox-1.0.js
⏰ 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: Seer Code Review
🔇 Additional comments (6)
webplugin/js/app/mck-sidebox-1.0.js (6)

13448-13448: LGTM!

The DOM element reference follows the existing pattern used for other UI elements in this file.


13462-13478: Well-structured timeout handling.

The timeout management correctly clears any existing timeout before setting a new one, preventing stacked timeouts. The 5-second auto-hide duration is reasonable for user notification.


13698-13707: LGTM!

The error handling correctly notifies the user and cleans up the pending message for validation failures before the upload attempt.


13754-13767: LGTM!

The integration correctly delegates error handling and returns early to prevent further processing when a file extension error is detected.


13915-13926: LGTM!

Consistent integration of the centralized error handler in the AWS upload path.


14170-14176: No refactoring needed—methods have different responsibilities despite similar patterns.

While showFileExtensionError and showMaliciousFileError share the first two operations (showing the upload icon and hiding the cancel icon), they diverge in their subsequent actions. showMaliciousFileError shows an additional error element, while showFileExtensionError hides the progress bar. Extracting common logic would add unnecessary parameters and reduce clarity. The current implementation is maintainable as-is.

@kandpal025 kandpal025 merged commit 968a369 into development Jan 11, 2026
6 checks passed
@AashishBhatt5 AashishBhatt5 mentioned this pull request Jan 12, 2026
3 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jan 30, 2026
3 tasks
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