aido-onyx/smb-connector/.env.example
Naeem Dosh ee281da0e5 SMB connector: handle non-UTF-8 (Windows/Latin-1) filenames
Client hit a crash on every cycle: filenames with non-UTF-8 bytes (e.g. 0xE4 = ä)
arrive from os.walk surrogate-escaped ('\udce4'), and encoding them to UTF-8 for
the id hash / ingestion JSON / manifest raised UnicodeEncodeError.

Fix: normalise each relative path once via _fs_safe() — recover the real on-disk
bytes (os.fsencode reverses surrogateescape) and decode with the share's codepage
(SMB_FILENAME_ENCODING, default cp1252) — so the id hash, the ingestion payload
and the manifest are all UTF-8/JSON-safe and the filename displays correctly
(Angebot_März.txt, not a crash). New SMB_FILENAME_ENCODING env; the previously
added SMB_SOURCE_<N>_MOUNT_OPTS also lets you pass iocharset at mount time.

Verified E2E against live Onyx with a real 0xE4 filename: no crash, indexed
'Angebot_März.txt', logical path '\company\sales\Angebot_März.txt' stored
correctly, manifest persisted, restart → 0/0/all-unchanged (stable id).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-10 00:34:32 +05:00

67 lines
3.3 KiB
Text

# ─────────────────────────────────────────────────────────────────────────────
# AIDO SMB → Onyx sync connector
# Copy to .env and adjust. The connector runs as a sidecar next to Onyx.
# ─────────────────────────────────────────────────────────────────────────────
# Onyx API base (in-compose service name; no trailing /api needed).
ONYX_API_URL=http://api_server:8080
# Auth — provide ONE of:
# (a) a pre-created API key (simplest), or
# (b) admin credentials so the connector creates + caches its own key on first boot.
ONYX_API_KEY=
# ONYX_ADMIN_EMAIL=admin@example.com
# ONYX_ADMIN_PASSWORD=change-me
# How often to reconcile each share (seconds).
INGESTION_INTERVAL_SECONDS=300
# File selection.
INCLUDE_EXTENSIONS=pdf,docx,txt,md,csv,xlsx,html,htm
MAX_FILE_MB=50
LOG_LEVEL=INFO
# Codepage for recovering filenames whose bytes aren't valid UTF-8 (common on
# Windows/Latin-1 shares, e.g. 0xE4 = ä). cp1252 = Western European (default).
# The connector handles such names correctly regardless of the CIFS mount charset;
# you can additionally pass iocharset via SMB_SOURCE_<N>_MOUNT_OPTS (see below).
SMB_FILENAME_ENCODING=cp1252
# ── Sources: SMB mounted INSIDE the container (recommended) ──────────────────
# Give each share its SMB connection details and the connector mounts it itself
# (CIFS) — no host mount required. Uses the indexed style so each source can carry
# credentials. Requires the cap_add + apparmor lines in docker-compose.smb.yml.
#
# _MOUNT = where to mount it inside the container (any path)
# _UNC = //server/share (or set _SERVER + _SHARE)
# _LOGICAL = the path users recognise; shown in Onyx's citation view
# _USERNAME/_PASSWORD/_DOMAIN = CIFS credentials (omit user for guest)
# _VERS = SMB dialect, default 3.0
# _CC_PAIR_ID (optional) = use a specific connector; auto-provisioned if omitted
SMB_SOURCE_1_NAME=Finance
SMB_SOURCE_1_UNC=//nas.company.local/finance
SMB_SOURCE_1_MOUNT=/mnt/smb/finance
SMB_SOURCE_1_LOGICAL=\\company\finance
SMB_SOURCE_1_USERNAME=svc_onyx
SMB_SOURCE_1_PASSWORD=change-me
SMB_SOURCE_1_DOMAIN=COMPANY
# SMB_SOURCE_1_VERS=3.0
# Extra raw CIFS mount options, appended verbatim to `mount -t cifs -o ...`.
# e.g. force the server's charset so filenames decode at mount time:
# SMB_SOURCE_1_MOUNT_OPTS=iocharset=utf8,nocase
# SMB_SOURCE_2_NAME=Legal
# SMB_SOURCE_2_SERVER=nas.company.local
# SMB_SOURCE_2_SHARE=legal
# SMB_SOURCE_2_MOUNT=/mnt/smb/legal
# SMB_SOURCE_2_LOGICAL=\\company\legal
# SMB_SOURCE_2_USERNAME=svc_onyx
# SMB_SOURCE_2_PASSWORD=change-me
# SMB_SOURCE_2_DOMAIN=COMPANY
# ── Legacy: host-mounted shares (still supported) ────────────────────────────
# If you'd rather mount on the host and bind-mount into the container, OMIT the
# _UNC/_SERVER lines for that source (so it isn't CIFS-mounted here) and point
# _MOUNT at the bind-mounted path. You can also use the JSON form:
# SMB_SOURCES=[{"name":"Finance","mount":"/mnt/smb/finance","logical":"\\\\company\\finance"}]