infiniflow/ragflow · error · ConnectorMissingCredentialError

GitLab

Error message

GitLab

What it means

ConnectorMissingCredentialError('GitLab') raised at the top of the GitLab connector's validate_connector_settings() when self.gitlab_client is None. The client is built only in load_credentials(), which requires both 'gitlab_url' and 'gitlab_access_token' keys; if validation runs first, this error fires before any GitLab request (auth() is the next step).

Source

Thrown at common/data_source/gitlab_connector.py:185

        include_issues: bool = True,
        include_code_files: bool = False,
    ) -> None:
        self.project_owner = project_owner
        self.project_name = project_name
        self.batch_size = batch_size
        self.state_filter = state_filter
        self.include_mrs = include_mrs
        self.include_issues = include_issues
        self.include_code_files = include_code_files
        self.gitlab_client: gitlab.Gitlab | None = None

    def load_credentials(self, credentials: dict[str, Any]) -> dict[str, Any] | None:
        self.gitlab_client = gitlab.Gitlab(credentials["gitlab_url"], private_token=credentials["gitlab_access_token"])
        return None

    def validate_connector_settings(self) -> None:
        if self.gitlab_client is None:
            raise ConnectorMissingCredentialError("GitLab")

        try:
            self.gitlab_client.auth()
            self.gitlab_client.projects.get(
                f"{self.project_owner}/{self.project_name}",
                lazy=True,
            )

        except gitlab.exceptions.GitlabAuthenticationError as e:
            raise CredentialExpiredError("Invalid or expired GitLab credentials.") from e

        except gitlab.exceptions.GitlabAuthorizationError as e:
            raise InsufficientPermissionsError("Insufficient permissions to access GitLab resources.") from e

        except gitlab.exceptions.GitlabGetError as e:
            raise ConnectorValidationError("GitLab project not found or not accessible.") from e

        except Exception as e:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Provide both gitlab_url and gitlab_access_token and call load_credentials() before validate_connector_settings().
  2. Ensure the credential dict contains both keys — load_credentials indexes them directly and a missing key aborts client construction.
  3. For self-hosted GitLab, double-check gitlab_url points at the instance root (e.g. https://gitlab.example.com).

Example fix

// before
connector = GitlabConnector(...)
connector.validate_connector_settings()  # raises ConnectorMissingCredentialError('GitLab')

# after
connector = GitlabConnector(...)
connector.load_credentials({'gitlab_url': 'https://gitlab.com', 'gitlab_access_token': token})
connector.validate_connector_settings()
Defensive patterns

Strategy: validation

Validate before calling

if connector.gitlab_client is None:
    connector.load_credentials({
        'gitlab_url': os.environ['GITLAB_URL'],
        'gitlab_access_token': os.environ['GITLAB_TOKEN'],
    })

Type guard

def gitlab_ready(c: GitlabConnector) -> bool:
    return c.gitlab_client is not None

Try / catch

try:
    connector.validate_connector_settings()
except ConnectorMissingCredentialError:
    show_credential_form('GitLab')

Prevention

When it happens

Trigger: Calling validate_connector_settings() on a GitLabConnector whose load_credentials({'gitlab_url': ..., 'gitlab_access_token': ...}) was never invoked — e.g. credential payload missing or skipped during connector setup.

Common situations: Saving a GitLab credential with a blank token; orchestration constructing the connector but not loading credentials before the validation hook; KeyError in load_credentials (missing key) leaving gitlab_client None.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/6eb15ec228a0a670. Report an issue: GitHub.