Unexpected exception when configuring file multiFileConverter for task 'Pre-translate Files': Failed to create an instance of translation provider 'sdltm.https://<groupshare-url.com>'.

Hi everyone,

I’m facing an issue with a tool I’ve developed that automates project creation using Trados templates.

I’ll outline how the tool works and the problem I’m encountering, hoping someone can guide me.

Tool Workflow:

  1. The tool retrieves a Trados template and associated files.
  2. It checks for Translation Providers and adds credentials, regardless of whether they were previously added or not.
  3. It runs the Automatic Tasks defined in the template.

Technical Details:

  1. Adding Credentials:
    1. The tool uses the AddCredential method from namespace Sdl.ProjectAutomation.FileBased to add credentials. Here’s the relevant code snippet:
      Fullscreen
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      public void AddCredential(Uri uri, string credential)
      {
      if (IsTermbaseServerUri(uri) || IsProjectServerUri(uri))
      {
      GenericCredentials genericCredentials = new GenericCredentials(credential);
      WCFToken samlToken = ((genericCredentials["SamlToken"] != null) ? JsonConvert.DeserializeObject<WCFToken>(genericCredentials["SamlToken"]) : null);
      UserCredentials userCredentials = new UserCredentials(genericCredentials.UserName, genericCredentials.Password, GetUserType(genericCredentials))
      {
      SamlToken = samlToken,
      AuthToken = genericCredentials["AuthToken"],
      ExpirationDate = ((genericCredentials["Exp"] != null) ? DateTime.Parse(genericCredentials["Exp"]) : default(DateTime))
      };
      switch (userCredentials.UserType)
      {
      case UserManagerTokenType.CustomUser:
      case UserManagerTokenType.CustomWindowsUser:
      IdentityInfoCache.Default.SetCustomIdentity(StripSchemePrefix(uri), userCredentials.UserName, userCredentials.Password);
      break;
      case UserManagerTokenType.WindowsUser:
      IdentityInfoCache.Default.SetWindowsIdentity(StripSchemePrefix(uri));
      break;
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    2. Credentials Format:
      Fullscreen
      1
      $"user={username};password={password};type=CustomUser"
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  2. Running Automatic Tasks:
    1. The tool then executes automatic tasks using the RunAutomaticTasks method from the same namespace:
      Fullscreen
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      public TaskSequence RunAutomaticTasks(Guid[] projectFileIds, string[] taskTemplateIds)
      {
      try
      {
      return RunAutomaticTasks(projectFileIds, taskTemplateIds, null, null);
      }
      catch (Exception exception)
      {
      Exception ex = ExceptionMapper.MapException(exception);
      throw ex;
      }
      }
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Issue Description:

  1. Initially, the tool works as expected.
  2. However, when the credentials expire (usually after 8 hours), the ‘Pre-translate Files’ task fails with the following error:
    Unexpected exception when configuring file multiFileConverter for task 'Pre-translate Files':
    Failed to create an instance of translation provider 'sdltm.https://<ourSdlServer>'.
  3. This error occurs even though I re-add credentials every time a new project is created using the AddCredential method.
  4. I suspect that the cached credentials are not being updated or replaced when new credentials are added.

Request for Assistance:

I’d appreciate help with the following:

  1. Can anyone confirm whether the credential cache is updated or cleared when AddCredential is called?
  2. Is there a mechanism to:
    1. Verify if credentials have expired and update them if so.
    2. Force the system to reset the cached authentication and use the new credentials added by the tool?
    3. Any recommendations to ensure that expired credentials do not cause task failures?

Thanks in advance for your insights and suggestions! Let me know if additional details are needed.