Invalid ConnectorId for "Internal" connector at worker initialization

Description

When the worker first starts, it looks for the connector "internal" by name. If an exception occurs, it attempts to create a new connector called "Internal.”

The issue arises when the connector already exists but another exception is thrown. The worker attempts to create a new one with a random ID but is unable to save it because another connector with the same name already exists.
The exception thrown by the creation is then ignored, and the new, unsaved connector is stored in the SystemLogHandler variable.

Any subsequent use of that worker instance will result in a Connector Not Found exception.

#Slack thread:
https://totvscarol.slack.com/archives/CFZ1562UB/p1702563943460059

Initialization Error:
https://cloudlogging.app.goo.gl/CS48uvSNVdY8GvtDA

Subsequent errors occurring in the same worker:
https://cloudlogging.app.goo.gl/kRd8u4G3oCu4RyBi8

Code to fix at SystemLogHandler.java:

ApplicationService connectorService = MdmSingletonManager.getInstance(ApplicationService.class);
    try {
      this.connector = connectorService.getConnectorByName(this.adminUad, CONNECTOR_NAME);
    } catch (Exception e) {
      this.connector = new Connector();
      this.connector.setMdmName(CONNECTOR_NAME);

      try {
        this.connector = connectorService.createConnector(adminUad, this.connector);
      } catch (Exception e2) {
        // ignore creation error
        logger.warn(MARKER, "Error setting up connector", e2);
      }
    }

Activity

Automation for Jira 16 January 2024, 16:40 Jira Internal Users

This issue was automatically transitioned to REGRESSION, as its PR was just merged into qa branch in Github.

Automation for Jira 16 January 2024, 16:40 Jira Internal Users

This issue was automatically transitioned to REGRESSION, as its PR was just merged into qa branch in Github.

Automation for Jira 16 January 2024, 16:02 Jira Internal Users

This issue was automatically transitioned to TESTED & MERGED, as its PR was just merged into develop branch in Github. PR Approved by olivandre,jwmoraes.

Automation for Jira 16 January 2024, 16:02 Jira Internal Users

Github user jwmoraes has just approved a PR (added as Shard Assignee in this Jira issue).

fix: https://totvslabs.atlassian.net/browse/CAPL-5245#icft=CAPL-5245 Create Internal Connector at dataloader and prevent invalid id to be …

Jonathan Willian Moraes 11 January 2024, 20:31 Jira Internal Users

Card validated by the QA team.

Automation for Jira 10 January 2024, 18:26 Jira Internal Users

This issue was automatically transitioned to QA REVIEW, as its PR was just approved in Github.

Automation for Jira 9 January 2024, 22:48 Jira Internal Users

This issue was automatically transitioned to REVIEW, as its PR (not DRAFT and not WIP) was just created in Github.

fix: https://totvslabs.atlassian.net/browse/CAPL-5245#icft=CAPL-5245 Create Internal Connector at dataloader and prevent invalid id to be …

Automation for Jira 2 January 2024, 20:56 Jira Internal Users

@Reinaldo Oliveira Machado Junior ,
@Geny Isam Hamud Herrera , @Douglas Coimbra Lopes

This issue was planned to be delivered until 2024-01-22. You can check that by consulting the issue in the Due Date field.

Dates already planned for this issue: 2024-01-22

If External Issue Link field is filled, customer was also informed on JIRA TOTVS.