Batch Task “Pretranslate”/ ”Word Count” API call fails randomly

After migrating to Trados Studio 2021 from SDL Trados Studio 2017, we have come across the following major issue in the implementation of our automated processes (using the Trados public APIs):

Batch Task “Pretranslate”/ ”Word Count”: randomly fails with the following exception:

“Unexpected exception when configuring file multiFileConverter for task 'Word Count': Failed to create an instance of translation provider 'sdltm.XXX/

“Unexpected exception when configuring file multiFileConverter for task 'Pre-translate Files': Failed to create an instance of translation provider 'sdltm.file:///P:/PathToTheTM/nameOfTheTm.sdltm'..”

 

This issue has been replicated on our side using a simple Filebased Project with 2 simple docx translatable files, an empty FileBased TM while running the batch task “Pretranslate” on a loop.

 

As you can see, this problem occurs both with FileBased and ServerBased TMs.

Through trial-and-error, we have noticed the following:

  • The problem occurs only with projects that have more than one translatable file.
  • The problem does not occur if the batch task is applied for each translatable file separately.
  • The problem will occur after running the task a couple of times. The first few times the task is run, there is no issue.
  • Once the problem occurs, it keeps occurring until either a long time has gone by or the PC is rebooted (even if after the problem occurs we try to run the batch task for each file separately).

Details of the Exception fetched From Visual Studio:

System.IndexOutOfRangeException

  HResult=0x80131508

  Message=Index was outside the bounds of the array.

  Source=Sdl.Core.PluginFramework

  StackTrace:

   at Sdl.Core.PluginFramework.ObjectRegistry`2.CreateObjects()

 

  This exception was originally thrown at this call stack:

    Sdl.Core.PluginFramework.ObjectRegistry<TExtensionAttribute, TExtensionType>.CreateObjects()

 

This is a serious issue with a major negative impact on our productivity.
Can anyone from RWS give me an official answer on what to do? This was working perfectly fine until the upgrade to Trados 2021.
Is this going to be fixed soon on an upcoming update?
Is there a way to circumvent the problem in the meantime?

Thank you in advance!


emoji
Parents
  • Hi,  !

    I added this code sample in which I automatically create projects from different folders using a template and place them all, pretranslated, in a new location.

    The way to use the app is by adding the following command line arguments when calling it:

    .\PretranslateProjectsCreatedFromTemplateSample.exe "<pathToTemplate>" "<pathToFolderWithTranslatatableFiles>" ... "<pathToFolderWithTranslatatableFiles>" "<pathToWhereTheProjectsWillBeCreated>" "<numberOfTimesTheOperationWillBeDone>" "s"

    You can add as many folders containing translatable files as you wish between the template path argument and the destination folder argument.

    The issue is not reproducible in this sample anymore.

    See if there's something different in the sample and add it to your code to test whether the issue still persists.

    emoji
  • Hello  ,

     

    Thank you for taking the time to answer.

    Unfortunately, the solution provided is really not a solution to the issue I am describing.

    First of all, it is not feasible to create a new project from a template when dealing with clients (clients usually send packages or projects with specific settings which should not overruled).

    Secondly, in your solution you do not run the batch tasks on a loop, which is where the issue lies; what you do is create projects on a loop.

    Once again, the issue lies in running multiple pre-translate tasks on a project.

    Please see this short code sample:

    https://bitbucket.org/t_kastanis/trados21issues/src/master/

    You can run the program with the following arguments in the command line:

    .\Trados2021.exe <PathToTheSdlprojFile> <timesToRunPretranslate>

    First, make a simple project manually with two or more files (NOT one) and add a simple TM file (it can even be empty), and then run the program.

    Make sure you add a big number to <timesToRunPretranslate> (e.g. 30) and run the program many times consecutively.

    Keep in mind, that running the “Pre-translate” task multiple times on an existing project is a key functionality to our workflow (and, I am guessing, other companies’ workflows). This means that this issue needs to be solved rather than patched with a workaround.

    Looking forward to your answer.

    emoji
  • Hello  !

    Unfortunately, it seems like a workaround will have to do for now.

    We discovered a similar issue for another team recently, but we were unable to identify the root cause after a preliminary investigation. Until we have more concrete information, we recommend the following workaround.

    Introduce a fail-safe action to automatically restart the process of running the project automation tasks when it discovers a failed attempt. This should open a new instance of the project and not use the same instance of the project with the failed attempt.

    You can find a code sample for this here.

    emoji
  • Hi Emanual,

    Thank you for your response.

    With great disappointment, I have to point out that neither this second solution provided works.
    I am under the impression that the time required for the resolution of such a serious bug is not properly invested.

    I am not quite sure if the code sample was supposed to be working as is, since I found some “bugs” that I had to fix in order to successfully run it.

    Regardless of the procedure, the result is that once the task fails, it continues to fail and that the workaround doesn’t work.

    Here is a screenshot of the output:

    Screenshot of Trados Studio error log showing repeated 'Object reference not set to an instance of an object' errors during 'Translate Files' task, indicating a persistent bug. 

    I will repeat myself and remind you that the fact that the same bug -referenced in a previous message of mine- was reported almost seven months ago and no resolution was found makes me very very nervous.

    As you know, Trados is quite an expensive product, for which we (as a company) have purchased a large number of licenses. This alone is a good enough reason to merit complete resolution of an issue, especially when this issue is encountered in one of the most common -and important- batch tasks.

    Until the full resolution of the bug, a workaround that works is mandatory.

    I will be expecting an update.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 1:42 PM (GMT 0) on 5 Mar 2024]
  • Hi   thank you for your feedback and the sample project; appreciated.

    I am not quite sure if the code sample was supposed to be working as is, since I found some “bugs” that I had to fix in order to successfully run it.

    Can you please create a PR with the bug fixes that you applied against the public project example on github that  provided to you?  It isn't often that we get third-party developers wanting to get involved, contributing to the sample projects, with the objective of helping other developers in solving problems/ workarounds.

    I am under the impression that the time required for the resolution of such a serious bug is not properly investe

    Although I understand your frustration in not having a solution or workaround to resolve this -> contrary to what you are suggesting, we have reorganized our priorities to review the problem you are reporting.

    I will repeat myself and remind you that the fact that the same bug -referenced in a previous message of mine- was reported almost seven months ago and no resolution was found makes me very very nervous.

    We are reviewing the issue you have reported here, in these days.  Have you reported this same issue in another form on the community; pls add the link here for reference.

    Until the full resolution of the bug, a workaround that works is mandatory.

    'Mandatory' might be a poor choice of wording here, unless you are ordering us to provide you with a workaround.  Are you ordering us to provide you with a workaround?

    Let's recap to understand where we are:

    1. We reviewed the problem that you presented, given the conditions you disclosed about your process.
    2. We have been able to reproduce the problem in at least one occasion where the proposed solution by  resolved the issue.
    3. We presented this as a potential solution so that you could confirm if it resolves the problem on your system
    4. You have reported that the proposed solution doesn't resolve the problem on your system.

    Correct?

    My Review:

    I have taken time this evening to review this issue, using your sample project and confirm that I can reproduce the same issue you are reporting.  Sometimes it occurs once, other times all the time.  I don't see a work around for this without reviewing the abstract levels from the Trados Studio solution.

    For now, I will escalate this issue to the Studio Team, but it might be that we pick this up and collaborate with the Studio team to resolve. We'll circle back to you once we have more concrete information.

     ,  

    Reproducible on Trados Studio 2021 SR2+ and 2022

    Tech Notes:

    After reviewing the sample project that you provided above, I would recommend to include the execution of the batch task within an iteration of the project target languages, as follows:

    var targetLanguages = studioProject.GetProjectInfo().TargetLanguages;
    foreach (var targetLanguage in targetLanguages)
    {
    	var targetFiles = studioProject.GetTargetLanguageFiles(targetLanguage);
    	var task = studioProject.RunAutomaticTask(
    		targetFiles.GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles);
    	//[...]
    }

    Note: this will not solve the problem you have discovered, but will enable you to separate execution of the batch tasks by target language.

    emoji
Reply
  • Hi   thank you for your feedback and the sample project; appreciated.

    I am not quite sure if the code sample was supposed to be working as is, since I found some “bugs” that I had to fix in order to successfully run it.

    Can you please create a PR with the bug fixes that you applied against the public project example on github that  provided to you?  It isn't often that we get third-party developers wanting to get involved, contributing to the sample projects, with the objective of helping other developers in solving problems/ workarounds.

    I am under the impression that the time required for the resolution of such a serious bug is not properly investe

    Although I understand your frustration in not having a solution or workaround to resolve this -> contrary to what you are suggesting, we have reorganized our priorities to review the problem you are reporting.

    I will repeat myself and remind you that the fact that the same bug -referenced in a previous message of mine- was reported almost seven months ago and no resolution was found makes me very very nervous.

    We are reviewing the issue you have reported here, in these days.  Have you reported this same issue in another form on the community; pls add the link here for reference.

    Until the full resolution of the bug, a workaround that works is mandatory.

    'Mandatory' might be a poor choice of wording here, unless you are ordering us to provide you with a workaround.  Are you ordering us to provide you with a workaround?

    Let's recap to understand where we are:

    1. We reviewed the problem that you presented, given the conditions you disclosed about your process.
    2. We have been able to reproduce the problem in at least one occasion where the proposed solution by  resolved the issue.
    3. We presented this as a potential solution so that you could confirm if it resolves the problem on your system
    4. You have reported that the proposed solution doesn't resolve the problem on your system.

    Correct?

    My Review:

    I have taken time this evening to review this issue, using your sample project and confirm that I can reproduce the same issue you are reporting.  Sometimes it occurs once, other times all the time.  I don't see a work around for this without reviewing the abstract levels from the Trados Studio solution.

    For now, I will escalate this issue to the Studio Team, but it might be that we pick this up and collaborate with the Studio team to resolve. We'll circle back to you once we have more concrete information.

     ,  

    Reproducible on Trados Studio 2021 SR2+ and 2022

    Tech Notes:

    After reviewing the sample project that you provided above, I would recommend to include the execution of the batch task within an iteration of the project target languages, as follows:

    var targetLanguages = studioProject.GetProjectInfo().TargetLanguages;
    foreach (var targetLanguage in targetLanguages)
    {
    	var targetFiles = studioProject.GetTargetLanguageFiles(targetLanguage);
    	var task = studioProject.RunAutomaticTask(
    		targetFiles.GetIds(), AutomaticTaskTemplateIds.PreTranslateFiles);
    	//[...]
    }

    Note: this will not solve the problem you have discovered, but will enable you to separate execution of the batch tasks by target language.

    emoji
Children