-
Notifications
You must be signed in to change notification settings - Fork 34
bugs with enableDocumentMinification: true, with or without supported media file #71
Copy link
Copy link
Closed
Description
Describe the bug
enableDocumentMinification: true silently fails with no file output when .docx contains no media; when it does contain a media, it ends up with an untranslated version in the output file (after having held the minified translated version for a moment)
To Reproduce
Steps to reproduce the behavior:
- using 1.19.1
- sample call (almost verbatim from README.md), where inputPath and outputPath are valid full path strings:
try {
await deeplClient.translateDocument(inputPath, outputPath, 'en', 'fr', { enableDocumentMinification: true });
} catch (error) {
// If the error occurs after the document was already uploaded,
// documentHandle will contain the document ID and key
if (error.documentHandle) {
const handle = error.documentHandle;
console.log(`Document ID: ${handle.documentId}, ` + `Document key: ${handle.documentKey}`);
} else {
console.log(`Error occurred during document upload: ${error}`);
}
}
- use translateDocument on a .docx containing only text (no media)
- notice that output document is not generated and no error is shown, even with
log.getLogger('deepl').setLevel('debug'); - notice that try/catch on
deeplClient.translateDocument - try the same, but put a break point on translator.js line 255:

- See that the error at that break point is similar to the following (and notice that the translated output file still temporarily exists with translated content at that point, although it doesn't at the end of the process):
'Error: Error: no such file or directory, c:\\some_temp_path_here\\document_minification_5c6962c1-db3f-4b7a-bada-d25fb1ac5e82\\original_media
at FsHelper.readdirSyncRecursive (C:\some_project_dir\\node_modules\\deepl-node\\dist\\fsHelper.js:37:19)
at DocumentMinifier.replaceMediaInDir (C:\some_project_dir\\node_modules\\deepl-node\\dist\\documentMinifier.js:280:50)
at DocumentMinifier.deminifyDocument (C:\some_project_dir\\node_modules\\deepl-node\\dist\\documentMinifier.js:175:14)
at DeepLClient.translateDocument (C:\some_project_dir\\node_modules\\deepl-node\\dist\\translator.js:250:34)
- Notice that temp folder contains "minifiedDoc.docx" and "extracted_doc", but not "original_media"
- Put a break point at the first line of function deminifyDocument.
- Now try the same process with a .docx that contains an image.
- Notice that at the deminifyDocument breakpoint, output file contains a minified translated version as expected.
- Let the process run and notice that the output file contains a deminified version (i.e. image is back), but the text is no longer translated. (i.e. seems like it repackaged the wrong file)
Expected behavior
- The translated file is still generated correctly even if it contains no media, that way we can always use
enableDocumentMinification: truewith no prior knowledge of .docx content. - When the code throws an unrecoverable error, it should bubble up to the caller, so it knows that the process failed.
- The deminified file should contain the translated version.
Desktop (please complete the following information):
- OS: Windows 11
- API version: 1.19.1
- NodeJS version: 18.20.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels