infiniflow/ragflow · critical · Error

Invalid chat_id: ${payload.chat_id}

Error message

Invalid chat_id: ${payload.chat_id}

What it means

Raised at the top of _fetch_from_gitlab when self.gitlab_client is None — i.e. the connector began ingesting before load_credentials() built a gitlab.Gitlab client. It is a programming/lifecycle error in the caller, not a GitLab-side failure.

Source

Thrown at api/channels/whatsapp/gateway-node/index.js:330

        const dropped = this.events.slice(0, this.events.length - 500);
        this.events = this.events.slice(-500);
        for (const oldEvent of dropped) {
          if (oldEvent.kind === 'message' && oldEvent.message_id) {
            this.messageStore.delete(oldEvent.message_id);
          }
        }
      }
      this.lastSnapshotAt = now();
    }
  }

  async send(payload) {
    if (!this.sock) {
      throw new Error('WhatsApp session is not running.');
    }
    const jid = normalizeJid(payload.chat_id);
    if (!jid) {
      throw new Error(`Invalid chat_id: ${payload.chat_id}`);
    }
    const text = String(payload.text || '');
    const options = {};
    if (payload.reply_to_message_id) {
      const quoted = this.messageStore.get(String(payload.reply_to_message_id));
      if (quoted) {
        options.quoted = quoted;
      }
    }
    await this.sock.sendMessage(jid, { text }, options);
    this.lastSnapshotAt = now();
  }

  async stop() {
    this.stopping = true;
    clearTimeout(this.restartTimer);
    this.restartTimer = null;
    const sock = this.sock;

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Ensure load_credentials() is called (and completes without exception) before any ingestion entry point
  2. Inspect why gitlab_client is still None after load_credentials — usually the credential dict lacks gitlab_access_token / gitlab_instance_url keys
  3. In custom code, assert connector.gitlab_client is not None (or lazily construct it) before calling load_from_state()

Example fix

# before
connector = GitlabConnector(...)
docs = connector.load_from_state()  # boom: client never built

# after
connector = GitlabConnector(...)
connector.load_credentials({"gitlab_access_token": tok, "gitlab_instance_url": url})
docs = connector.load_from_state()
Defensive patterns

Strategy: validation

Validate before calling

def ready_to_index(connector) -> bool:
    return connector.gitlab_client is not None

# gate before ingestion
assert ready_to_index(connector), "call load_credentials() before indexing"

Type guard

from typing import assert_type

def has_loaded_client(conn) -> bool:
    return getattr(conn, "gitlab_client", None) is not None

Try / catch

from common.data_source.exceptions import ConnectorMissingCredentialError

try:
    docs = connector.load_from_state()
except ConnectorMissingCredentialError:
    connector.load_credentials(creds)  # complete lifecycle, then retry once
    docs = connector.load_from_state()

Prevention

When it happens

Trigger: Calling load_from_state()/poll_source()/ _fetch_from_gitlab() directly without first calling load_credentials(credentials_dict), or load_credentials returning early on a malformed credential payload so client construction was skipped.

Common situations: Test harness instantiating the connector and immediately indexing, orchestrator bug that skips the credential-loading step, credential dict missing the token key so client init was bypassed.

Related errors


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