From f3ab7f4cee04ed9150c36d386eb6ca2357dd6c46 Mon Sep 17 00:00:00 2001 From: Naeem Dosh Date: Thu, 10 Sep 2026 23:14:28 +0500 Subject: [PATCH] SMB connector: fix stuck 'Initial Indexing', configurable name prefix + timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four items from client feedback: 1. Stuck 'Initial Indexing' status. Root cause (by design in Onyx): docprocessing/utils.py never runs a classic index attempt for INGESTION_API connectors — documents are pushed via the API, not polled — so last_finished_status stays null and the badge is stuck even though the docs are indexed and searchable (also why it's safe: no risk of re-index deleting the pushed docs). Two-part fix: - Connector now sets each cc_pair ACTIVE after provisioning (set_cc_pair_active), which fixes the connector detail page + 'Active Connectors' count. - Frontend overlay (branding/smb/smb-ui.patch): the Ingestion table shows the real cc_pair_status for ingestion_api connectors instead of forcing 'Initial Indexing'. Verified live: new cc_pair comes up ACTIVE. 2. Connector name now configurable: ONYX_CONNECTOR_NAME_PREFIX (default 'AIDO SMB'). 3. HTTP timeout now configurable: ONYX_HTTP_TIMEOUT (default 60), for large embeds. 4. (Phase 2 already delivered in ab64692 — the preview/path overlay.) Verified live against running Onyx: provisioning sets ACTIVE, custom prefix 'Livtec Docs - Sales' applied, timeout honoured, ä-filename still indexed. Full overlay apply green, no conflict markers, connector modules parse. Co-Authored-By: Claude Opus 4.8 --- branding/smb/smb-ui.patch | 19 +++++++++++++++++++ smb-connector/.env.example | 5 +++++ smb-connector/app/config.py | 6 ++++++ smb-connector/app/main.py | 2 +- smb-connector/app/onyx_client.py | 21 +++++++++++++++++++++ smb-connector/app/sync.py | 2 +- 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/branding/smb/smb-ui.patch b/branding/smb/smb-ui.patch index e58ba6f..74ec068 100644 --- a/branding/smb/smb-ui.patch +++ b/branding/smb/smb-ui.patch @@ -1,3 +1,22 @@ +diff --git a/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx +index 39061740..04cf8794 100644 +--- a/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx ++++ b/web/src/app/admin/indexing/status/CCPairIndexingStatusTable.tsx +@@ -175,7 +175,13 @@ function ConnectorRow({ + + - "). +ONYX_CONNECTOR_NAME_PREFIX=AIDO SMB +# HTTP timeout (s) for Onyx API calls — raise it for large files / slow embeddings. +ONYX_HTTP_TIMEOUT=60 + # File selection. INCLUDE_EXTENSIONS=pdf,docx,txt,md,csv,xlsx,html,htm MAX_FILE_MB=50 diff --git a/smb-connector/app/config.py b/smb-connector/app/config.py index 3d7bf12..48da467 100644 --- a/smb-connector/app/config.py +++ b/smb-connector/app/config.py @@ -57,6 +57,8 @@ class Config: max_file_mb: int log_level: str filename_encoding: str = "cp1252" + connector_name_prefix: str = "AIDO SMB" + http_timeout: int = 60 sources: list[SourceConfig] = field(default_factory=list) @@ -143,6 +145,10 @@ def load_config() -> Config: # Codepage used to recover filenames whose bytes aren't valid UTF-8 (common # on Windows/Latin-1 shares, e.g. 0xE4 = ä). cp1252 covers Western European. filename_encoding=os.environ.get("SMB_FILENAME_ENCODING", "cp1252"), + # Prefix for the auto-created Onyx connector names (" - "). + connector_name_prefix=os.environ.get("ONYX_CONNECTOR_NAME_PREFIX", "AIDO SMB"), + # HTTP timeout for Onyx API calls; raise it for large embeddings/ingests. + http_timeout=int(os.environ.get("ONYX_HTTP_TIMEOUT", "60")), sources=_load_sources(), ) if not cfg.sources: diff --git a/smb-connector/app/main.py b/smb-connector/app/main.py index f85c60f..89ce284 100644 --- a/smb-connector/app/main.py +++ b/smb-connector/app/main.py @@ -48,7 +48,7 @@ def main() -> int: signal.signal(signal.SIGINT, _handle_signal) state = State.load(cfg.state_path) - client = OnyxClient(cfg.api_url, cfg.api_key) + client = OnyxClient(cfg.api_url, cfg.api_key, timeout=cfg.http_timeout) client.set_admin_credentials(cfg.admin_email, cfg.admin_password) try: diff --git a/smb-connector/app/onyx_client.py b/smb-connector/app/onyx_client.py index de73220..6be3966 100644 --- a/smb-connector/app/onyx_client.py +++ b/smb-connector/app/onyx_client.py @@ -157,6 +157,7 @@ class OnyxClient: existing = self.find_cc_pair_id_by_name(name) if existing: logger.info("Reusing existing connector '%s' (cc_pair_id=%s)", name, existing) + self.set_cc_pair_active(existing) return existing connector = { @@ -188,8 +189,28 @@ class OnyxClient: if not cc: raise OnyxError(f"could not determine cc_pair_id after provisioning: {body}") logger.info("Provisioned connector '%s' → cc_pair_id=%s", name, cc) + self.set_cc_pair_active(int(cc)) return int(cc) + def set_cc_pair_active(self, cc_pair_id: int) -> None: + """Mark the cc_pair ACTIVE. Onyx never runs a classic index attempt for + ingestion-API connectors (docs are pushed via the API, not polled), so + without this they sit in SCHEDULED/INITIAL_INDEXING forever. Best-effort.""" + try: + resp = self._request( + "PUT", + f"/manage/admin/cc-pair/{cc_pair_id}/status", + json={"status": "ACTIVE"}, + auth=self._admin_auth, + ) + if resp.status_code >= 400: + logger.warning( + "Could not set cc_pair %s ACTIVE [%s]: %s", + cc_pair_id, resp.status_code, resp.text[:200], + ) + except OnyxError as exc: + logger.warning("Could not set cc_pair %s ACTIVE: %s", cc_pair_id, exc) + # -- helpers ------------------------------------------------------------- _admin_email: str | None = None _admin_password: str | None = None diff --git a/smb-connector/app/sync.py b/smb-connector/app/sync.py index b4a42f4..2a8ae39 100644 --- a/smb-connector/app/sync.py +++ b/smb-connector/app/sync.py @@ -116,7 +116,7 @@ def sync_source(client: OnyxClient, cfg: Config, source: SourceConfig, state: St ss = state.source(source.name) cc_pair_id = source.cc_pair_id or ss.cc_pair_id if not cc_pair_id: - cc_pair_id = client.provision_cc_pair(f"AIDO SMB - {source.name}") + cc_pair_id = client.provision_cc_pair(f"{cfg.connector_name_prefix} - {source.name}") ss.cc_pair_id = cc_pair_id state.save()