Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions ui/src/components/LegacyCms/Actions/LoadFileFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const LoadFileFormat = (_props: LoadFileFormatProps) => {
isactive: true,
title: extractedFormat === 'zip' ? 'Zip' : extractedFormat.toUpperCase()
};

console.info('LoadFileFormat: DISPATCHING FILE FORMAT:', fileFormatObj);


dispatch(updateNewMigrationData({
...newMigrationData,
legacy_cms: {
Expand All @@ -69,31 +67,29 @@ const LoadFileFormat = (_props: LoadFileFormatProps) => {
}
}));

setFileIcon(fileFormatObj.title);
setFileIcon(fileFormatObj?.title);
}
} else if (!isEmptyString(currentFormat)) {
setFileIcon(currentFormat);
}
}, [newMigrationData?.legacy_cms?.uploadedFile?.file_details?.localPath, newMigrationData?.legacy_cms?.selectedFileFormat, dispatch, newMigrationData]);


return (
<div className="p-3">
<div className="col-12">
<label htmlFor="file-format">
<TextInput
value={fileIcon === 'Folder' ? 'DIRECTORY' : fileIcon ? fileIcon : 'file extension not found'}
label="File Format"
value={fileIcon || 'File extension not found'}
version="v2"
isReadOnly={true}
disabled={true}
width="large"
placeholder=""
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.
size="medium"
version="v2"
aria-label="fileformat"
aria-label="File format icon"
/>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion upload-api/src/services/fileProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const handleFileProcessing = async (
file_details: config
};
}
} else if (fileExt === 'xml') {
} else if (fileExt === 'xml' && (cmsType === 'wordpress' || cmsType === 'drupal')) {
if (await validator({ data: zipBuffer, type: cmsType, extension: fileExt })) {
Comment on lines +44 to 45
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.
const $ = Cheerio.load(zipBuffer, { xmlMode: true });
const fixedXml = $.xml();
Expand Down
Loading