infiniflow/ragflow · error · ConnectorMissingCredentialError

Discord

Error message

Discord

What it means

Raised by the discord_bot_token property when self._discord_bot_token is None. The token is only set in load_credentials() (via credentials['discord_bot_token']), so any read before that step — or after a credential dict missing that key raised KeyError and was swallowed — trips this guard.

Source

Thrown at common/data_source/discord_connector.py:254

    def __init__(
        self,
        server_ids: list[str] | None = None,
        channel_names: list[str] | None = None,
        # YYYY-MM-DD
        start_date: str | None = None,
        batch_size: int = INDEX_BATCH_SIZE,
    ):
        self.batch_size = batch_size
        self.channel_names: list[str] = channel_names if channel_names else []
        self.server_ids: list[int] = [int(server_id) for server_id in server_ids] if server_ids else []
        self._discord_bot_token: str | None = None
        self.requested_start_date_string: str = start_date or ""

    @property
    def discord_bot_token(self) -> str:
        if self._discord_bot_token is None:
            raise ConnectorMissingCredentialError("Discord")
        return self._discord_bot_token

    def _iter_merged_documents(
        self,
        start: datetime | None = None,
        end: datetime | None = None,
    ) -> GenerateDocumentsOutput:
        """Build merged Discord documents for the requested polling window."""
        doc_batch: list[Document] = []

        def _message_created_at(message: DiscordMessage) -> datetime:
            created_at = message.created_at
            if created_at.tzinfo is None:
                return created_at.replace(tzinfo=timezone.utc)
            return created_at.astimezone(timezone.utc)

        def _is_in_window(message: DiscordMessage) -> bool:
            created_at = _message_created_at(message)

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Call load_credentials({'discord_bot_token': '<token>'}) before any polling/indexing method
  2. Ensure the credential payload actually contains the 'discord_bot_token' key (KeyError in load_credentials means it never landed)
  3. Treat ConnectorMissingCredentialError as non-retriable: fix the credential config, then restart the run

Example fix

// before
connector = DiscordConnector(...)
connector.poll_source(start, end)  # raises

// after
connector = DiscordConnector(...)
connector.load_credentials({'discord_bot_token': token})
connector.poll_source(start, end)
Defensive patterns

Strategy: validation

Validate before calling

if 'discord_bot_token' not in credentials or not credentials['discord_bot_token']:
    raise ValueError('discord_bot_token required')

Prevention

When it happens

Trigger: Calling _iter_merged_documents/poll_source/load_from_state before load_credentials; load_credentials raised KeyError('discord_bot_token') earlier and the caller proceeded.

Common situations: Scripts constructing DiscordConnector directly; orchestrator catching the KeyError from a malformed credential payload but continuing the run.

Related errors


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