Skip to content

Conversation

@sayalijoshi27
Copy link
Contributor

This PR contains fix
[CMG-769] - If the CMS type is AEM, and the uploaded file path has an extension like .xml or something else, the system still validates it — but it should not.

@sayalijoshi27 sayalijoshi27 requested a review from a team as a code owner November 20, 2025 11:40
@umeshmore45 umeshmore45 requested a review from Copilot November 20, 2025 11:46
Copilot finished reviewing on behalf of umeshmore45 November 20, 2025 11:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses CMG-769 to fix XML file validation logic for different CMS types, specifically to prevent AEM files with XML extensions from being validated.

  • Modified XML validation conditional to only validate XML files for WordPress and Drupal CMS types
  • Cleaned up UI component code including console statements and improved accessibility attributes
  • Simplified file format display logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
upload-api/src/services/fileProcessing.ts Added CMS type check to XML validation condition to exclude AEM files from WordPress/Drupal XML processing
ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx Removed debug console statements, added label prop, improved value display logic, and updated icon condition check

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to 45
} else if (fileExt === 'xml' && (cmsType === 'wordpress' || cmsType === 'drupal')) {
if (await validator({ data: zipBuffer, type: cmsType, extension: fileExt })) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

This change has two issues:

  1. Drupal XML validation will fail: The condition now allows cmsType === 'drupal', but the validator function doesn't have a case for 'drupal-xml'. When called with type='drupal' and extension='xml', the validator will return false (default case), causing all Drupal XML files to be rejected.

  2. AEM files still validated: According to the PR description, AEM files with XML extensions should not be validated. However, with this change, AEM XML files will skip this block (which is correct) but then fall through to the else block (lines 95-119) where they'll still be validated. Since there's no 'aem-xml' validator case, they'll fail validation and be rejected.

Consider adding appropriate validator cases in validators/index.ts for 'drupal-xml' and any AEM file extensions that should be supported without validation.

Suggested change
} else if (fileExt === 'xml' && (cmsType === 'wordpress' || cmsType === 'drupal')) {
if (await validator({ data: zipBuffer, type: cmsType, extension: fileExt })) {
} else if (fileExt === 'xml' && cmsType === 'aem') {
// For AEM XML files, skip validation and accept the file
const $ = Cheerio.load(zipBuffer, { xmlMode: true });
const fixedXml = $.xml();
const parsedJson = await parseXmlToJson(fixedXml);
const isSaved = await saveJson(parsedJson, `${name}.json`);
if (isSaved) {
logger.info('AEM XML file accepted without validation:', {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.VALIDATION_SUCCESSFULL
});
return {
status: HTTP_CODES?.OK,
message: HTTP_TEXTS?.VALIDATION_SUCCESSFULL,
file_details: config
};
} else {
logger.warn('AEM XML file save error:', {
status: HTTP_CODES?.UNAUTHORIZED,
message: HTTP_TEXTS?.VALIDATION_ERROR
});
return {
status: HTTP_CODES?.UNAUTHORIZED,
message: HTTP_TEXTS?.VALIDATION_ERROR,
file_details: config
};
}
} else if (fileExt === 'xml' && (cmsType === 'wordpress' || cmsType === 'drupal')) {
// For Drupal and WordPress XML files, validate appropriately
let validatorType = cmsType;
if (cmsType === 'drupal' && fileExt === 'xml') {
validatorType = 'drupal-xml'; // Use a specific validator type for Drupal XML
}
if (await validator({ data: zipBuffer, type: validatorType, extension: fileExt })) {

Copilot uses AI. Check for mistakes.
prefix={
<Icon
icon={fileIcon ? fileIcon : 'CrashedPage'}
icon={fileIcon === 'DIRECTORY' ? 'Folder' : fileIcon ? fileIcon : 'CrashedPage'}
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Inconsistent folder/directory handling. The old code checked fileIcon === 'Folder' for both the value display and icon selection. The new code checks fileIcon === 'DIRECTORY' on line 89, but there's no code that sets fileIcon to 'DIRECTORY'. The fileIcon is set from selectedFileFormat?.title (lines 70, 73) or extracted from the file extension (line 59), neither of which would produce 'DIRECTORY'. This means the Folder icon will never be shown. Consider changing line 89 to check for fileIcon === 'Folder' instead.

Suggested change
icon={fileIcon === 'DIRECTORY' ? 'Folder' : fileIcon ? fileIcon : 'CrashedPage'}
icon={fileIcon === 'Folder' ? 'Folder' : fileIcon ? fileIcon : 'CrashedPage'}

Copilot uses AI. Check for mistakes.
@umeshmore45 umeshmore45 merged commit 4590803 into dev Nov 20, 2025
13 checks passed
@umeshmore45 umeshmore45 deleted the feature/aem-final branch November 20, 2025 12:21
@sayalijoshi27 sayalijoshi27 restored the feature/aem-final branch November 20, 2025 12:47
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