infiniflow/ragflow · error · ConnectorMissingCredentialError

BigQuery: missing service_account_json

Error message

BigQuery: missing service_account_json

What it means

BigQuery connector's load_credentials raises ConnectorMissingCredentialError when the credentials dict has no truthy 'service_account_json' entry. The value may be a dict or a JSON string; absent, empty string, or None all trigger this. No Google API call is made — it fails fast locally.

Source

Thrown at common/data_source/bigquery_connector.py:153

        self._cursor_param_type: Optional[str] = None
        self._sync_connector_id: str | None = None
        self._sync_config: Dict[str, Any] | None = None
        self._pending_sync_cursor_value: Any = None
        self._pending_sync_cursor_id: Any = None

    # ------------------------------------------------------------------ #
    # Credentials & client
    # ------------------------------------------------------------------ #
    def load_credentials(self, credentials: Dict[str, Any]) -> Dict[str, Any] | None:
        """Load BigQuery service-account credentials.

        Accepts ``service_account_json`` as either a dict or a JSON string.
        """
        logging.debug("Loading credentials for BigQuery project: %s", self.project_id)

        raw = (credentials or {}).get("service_account_json")
        if not raw:
            raise ConnectorMissingCredentialError("BigQuery: missing service_account_json")

        if isinstance(raw, str):
            try:
                service_account_info = json.loads(raw)
            except json.JSONDecodeError as exc:
                raise ConnectorMissingCredentialError(f"BigQuery: service_account_json is not valid JSON: {exc}")
        elif isinstance(raw, dict):
            service_account_info = raw
        else:
            raise ConnectorMissingCredentialError("BigQuery: service_account_json must be a JSON string or object")

        self._credentials = {"service_account_info": service_account_info}
        return None

    def _get_client(self):
        """Create and cache a BigQuery client from the loaded service account."""
        if self._client is not None:
            return self._client

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Add 'service_account_json' to the credentials dict, either as the parsed JSON object or the raw JSON string from the GCP console
  2. Fix the secrets-manager key mapping so the value lands under service_account_json
  3. Sanity-check the value is non-empty before calling load_credentials

Example fix

# before
creds = {"service_account": sa_json}  # wrong key
connector.load_credentials(creds)

# after
creds = {"service_account_json": sa_json}
connector.load_credentials(creds)
Defensive patterns

Strategy: validation

Validate before calling

def validate_bigquery_creds(creds: dict) -> None:
    raw = creds.get("service_account_json")
    if not raw:
        raise ValueError("credentials must include a non-empty 'service_account_json'")
    if not isinstance(raw, (str, dict)):
        raise TypeError("service_account_json must be a str or dict")

Type guard

def has_service_account_json(c: dict) -> bool:
    raw = c.get("service_account_json")
    return isinstance(raw, (str, dict)) and bool(raw)

Try / catch

try:
    connector.load_credentials(creds)
except ConnectorMissingCredentialError as e:
    raise ConfigError(str(e)) from e  # show as form/config error

Prevention

When it happens

Trigger: Calling load_credentials with a dict lacking the service_account_json key, with an empty string, or with None — commonly when the credential is stored under a different key name or the secrets integration returned nothing.

Common situations: Secrets manager path misconfigured so the fetched secret never lands in service_account_json, key named 'service_account' or 'credentials_json' by mistake, or an empty value written during initial setup that was never filled in.

Related errors


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