infiniflow/ragflow · error · ConnectorMissingCredentialError

Box

Error message

Box

What it means

Raised by BoxConnector.validate_connector_settings when self.box_client is None, i.e. load_credentials(auth) was never called. Unlike most connectors, Box auth is passed as an already-built BoxSDK auth object (e.g. BoxOAuth, BoxJWTAuth, or CCG auth), and load_credentials wraps it in a BoxClient. The message 'Box' identifies the connector whose credentials were not loaded.

Source

Thrown at common/data_source/box_connector.py:31

from common.data_source.interfaces import LoadConnector, PollConnector, SecondsSinceUnixEpoch
from common.data_source.models import Document, GenerateDocumentsOutput, GenerateSlimDocumentOutput, SlimDocument
from common.data_source.utils import get_file_ext


class BoxConnector(LoadConnector, PollConnector):
    def __init__(self, folder_id: str, batch_size: int = INDEX_BATCH_SIZE, use_marker: bool = True) -> None:
        self.batch_size = batch_size
        self.folder_id = "0" if not folder_id else folder_id
        self.use_marker = use_marker
        self.box_client: BoxClient | None = None

    def load_credentials(self, auth: Any):
        self.box_client = BoxClient(auth=auth)
        return None

    def validate_connector_settings(self):
        if self.box_client is None:
            raise ConnectorMissingCredentialError("Box")

        try:
            self.box_client.users.get_user_me()
        except Exception as e:
            logging.exception("[Box]: Failed to validate Box credentials")
            raise ConnectorValidationError(f"Unexpected error during Box settings validation: {e}")

    def _iter_files_recursive(
        self,
        folder_id: str,
        relative_folder_path: str = "",
    ) -> Generator[tuple[Any, str], None, None]:
        if self.box_client is None:
            raise ConnectorMissingCredentialError("Box")

        result = self.box_client.folders.get_folder_items(
            folder_id=folder_id,
            limit=self.batch_size,

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Build a BoxSDK auth object (CCG: BoxCCGAuth(BoxClientAuth(...)); JWT: BoxJWTAuth; OAuth: BoxOAuth) and call load_credentials(auth) before validating
  2. Verify the auth prerequisites exist: client_id, client_secret, and enterprise id (CCG) or a signed JWT keypair
  3. Ensure the OAuth access token in the auth object is fresh — expired tokens fail later at get_user_me, not here
  4. Fix orchestration ordering: load_credentials -> validate_connector_settings

Example fix

// before
connector = BoxConnector(folder_id='12345')
connector.validate_connector_settings()  # raises
// after
from boxsdk import CCGAuth, Client as BoxSdkClient
ccg = CCGAuth(client_id=cid, client_secret=csec, enterprise_id=eid)
connector = BoxConnector(folder_id='12345')
connector.load_credentials(auth=ccg)
connector.validate_connector_settings()
Defensive patterns

Strategy: validation

Validate before calling

if connector.box_client is None:
    raise RuntimeError('call load_credentials(auth) with a BoxSDK auth object first')
connector.validate_connector_settings()

Type guard

def is_box_ready(c: BoxConnector) -> bool:
    return c.box_client is not None

Try / catch

from common.data_source.exceptions import ConnectorMissingCredentialError
try:
    connector.validate_connector_settings()
except ConnectorMissingCredentialError:
    report('Box auth not configured — complete OAuth or provide CCG/JWT secrets')

Prevention

When it happens

Trigger: Constructing BoxConnector(folder_id) and calling validate_connector_settings() before load_credentials(auth); or the orchestration flow that should build the BoxSDK auth object (OAuth token from the redirect flow, JWT/CCG service account) failed silently upstream.

Common situations: Onyx indexing worker for the Box connector started without completing the OAuth flow or without the JWT/CCG secrets (client id/secret, enterprise id, keypair); test harnesses building the connector directly; credential refresh path that replaces the auth object but never reassigns box_client.

Related errors


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