Skip to content

Troubleshooting ​

This guide provides diagnostic playbooks for the five operational layers of LatticeDX: Keycloak OIDC/PKCE authentication, PostgreSQL 16 FORCE ROW LEVEL SECURITY, Docker Compose network segmentation, the IIoT pipeline (Mosquitto, Node-RED, Orion-LD), and AI/MCP gateways. Run read-only inspection queries before mutating container state or secrets.

Quick Symptom Matrix ​

Subsystem Triage Reference
ParameterTypeDefaultDescription
OIDC 401 or Callback Loop
Keycloak + Valkey DB 2—Check issuer mismatch between DX_NATIVE_AUTH_ISSUER and DX_NATIVE_AUTH_INTERNAL_ISSUER or expired 60s ticket: keys.
Empty RLS Results / 42501
PG16 + nocobase_app—Verify DX_PG_RLS_SESSION=true, transaction-local app.current_org, and NOBYPASSRLS on nocobase_app.
Inter-Service Timeouts
Docker Networks—Verify shared internal network membership (app, data, scanner, iiot-net) and container healthchecks.
IIoT Drops / Outbox Backlog
Mosquitto + Orion-LD—Inspect dynamic-security.json ACLs, SSRF host allowlists, and failed rows in latticeContextOutbox.
AI / RAG Errors or Dropped Spans
plugin-dxos-ai—Check AGENT_BASE_URL, DX_EMBEDDING_DIM=1536 alignment, and OTel queue counters on /api/dxos:health.

1. Keycloak OIDC, PKCE S256, and Session Revocation ​

plugin-enterprise-auth separates browser-facing issuer URLs (DX_NATIVE_AUTH_ISSUER) from server-to-Keycloak internal traffic (DX_NATIVE_AUTH_INTERNAL_ISSUER) and stores short-lived PKCE state inside Valkey DB 2.

Symptoms: invalid_state, Expired ticket, or Missing Role Mapping ​

Root CauseVerification & Remediation
Public vs. internal issuer mismatchWhen DX_NATIVE_AUTH_ISSUER points to https://${KEYCLOAK_DOMAIN}/realms/lattice while DX_NATIVE_AUTH_INTERNAL_ISSUER is unset or misrouted, token exchange inside /api/enterpriseAuth:callback fails. Confirm DX_NATIVE_AUTH_ORIGIN matches the exact browser scheme and hostname.
Valkey DB 2 TTL expirationPKCE state: keys expire after 300s, and single-use ticket: keys (paired with the HttpOnly ldx_enterprise_binding cookie) expire after 60s. Network stalls, cookie-stripping proxies, or host clock skew beyond those bounds reject /api/enterpriseAuth:finish.
Brute-force lockout or filtered role mappingThe production realm (lattice-realm.prod.json) enables bruteForceProtected: true (locking accounts after 5 failed attempts). When verifying group sync, note that DX_NATIVE_AUTH_GROUP_ROLE_MAP in policy.js intentionally skips privileged roles (ldx_admin, allowConfigure, pm*) to prevent privilege escalation through OIDC group claims.
bash
# From host (local stack)
curl -fsS http://127.0.0.1:8081/realms/lattice/.well-known/openid-configuration | jq "{issuer, token_endpoint, jwks_uri}"

# From inside nocobase container against internal issuer
docker compose -f infra/compose/prod.yml exec nocobase node -e "fetch(process.env.DX_NATIVE_AUTH_INTERNAL_ISSUER + '/.well-known/openid-configuration').then(r=>console.log(r.status))"

2. PostgreSQL 16 FORCE RLS (app.current_org and nocobase_app) ​

All 56 static tenant tables and dynamic latticeCustom* tables enforce ENABLE and FORCE ROW LEVEL SECURITY using transaction-local GUC settings app.current_org and app.rls_bypass.

Symptoms: Zero Rows Returned, 42501 Violations, or 25P02 Aborted Transactions ​

Root CauseVerification & Remediation
Missing transaction-local set_configQueries executed directly on the pool outside withTenantRlsContext or withSystemRlsBypass (or with DX_PG_RLS_SESSION disabled) evaluate current_setting('app.current_org', true) as empty, causing lattice_tenant_isolation to filter out all rows.
25P02 (current transaction is aborted)Running an optional query inside an open RLS transaction without runInRlsSavepoint (SAVEPOINT "ldx_sp_<n>") aborts the entire outer transaction until rollback.
Incorrect database role privilegesinit-nocobase-db.sh requires NOCOBASE_APP_DB_USER (nocobase_app) to differ from POSTGRES_USER and enforces NOSUPERUSER NOBYPASSRLS. Connecting the runtime application with a superuser migration role (nocobase or postgres) bypasses FORCE ROW LEVEL SECURITY.
sql
-- 1. Confirm nocobase_app does not hold BYPASSRLS
SELECT rolname, rolsuper, rolbypassrls FROM pg_roles WHERE rolname IN ('nocobase_app', 'nocobase', 'lattice_app');

-- 2. Inspect active policies on sample camelCase and snake_case tables
SELECT schemaname, tablename, policyname, qual, with_check
FROM pg_policies
WHERE tablename IN ('latticeOrders', 'lattice_native_request_attachments');

3. Docker Compose Networking, Gateway, and Auxiliary Services ​

infra/compose/prod.yml isolates traffic across 5 Docker networks: edge (external ingress for Caddy, Keycloak, APISIX, and NocoBase), app (internal: true), data (internal: true), scanner (internal: true), and iiot-net (internal: true).

Symptoms: ECONNREFUSED Across Containers, CORS Stripping, or Pending File Scans ​

Root CauseVerification & Remediation
Missing Compose profile or network segmentationVerify optional profiles (observability, iiot, n8n, pdf, iam-sync) are active when expected. In local development, run pnpm local:doctor --integration to probe api, keycloak, nocobase, orion-ld, and n8n without mutating state.
CORS headers stripped by DX_CORS_STRICT=trueThe middleware in observability.js strips Access-Control-Allow-* headers whenever an incoming Origin fails validation against DX_CORS_ALLOWED_ORIGINS or the request host.
Stuck pending file uploadsfile-scanner:4010 communicates with clamav:3310 over the isolated scanner network. If clamav is refreshing virus definitions or hits its 2048m memory limit, pending uploads remain queued until DX_UPLOAD_STALE_PENDING_MS (900000 ms). Inspect tmpfs capacity and clamdcheck.sh status inside the container.
bash
pnpm local:doctor --integration
docker compose -f infra/compose/core.yml -f infra/compose/nocobase.yml ps

4. IIoT Stack: Mosquitto DynSec, Node-RED, and FIWARE Orion-LD ​

Edge telemetry flows through mosquitto:1883 (bound strictly to iiot-net) into nodered:1880, then syncs with nocobase and orion-ld:1026.

Symptoms: MQTT Auth Denials or latticeContextOutbox failed Backlog ​

Root CauseVerification & Remediation
MQTT client denied or downlink commands droppedmosquitto.conf sets allow_anonymous false and init-dynsec.sh sets default ACL access to deny. The MQTT_BRIDGE_USER account is scoped to subscribe on latticedx/# and publish commands on latticedx/+/+/command. Rotating MQTT_BRIDGE_PASSWORD after /mosquitto/data/dynamic-security.json has been initialized requires updating the client password via mosquitto_ctrl dynsec.
SSRF host allowlist rejectionsOrion-LD and Node-RED outbound calls fail closed unless target hostnames match DX_ORION_HOST_ALLOWLIST, DX_ORION_CALLBACK_HOST_ALLOWLIST, and DX_NODERED_HOST_ALLOWLIST.
Stuck latticeContextOutbox rowsThe 10-second outbox drainer uses FOR UPDATE OF o SKIP LOCKED per entity. Crashed worker locks expire after DX_OUTBOX_STALE_LOCK_MS (120000 ms), while rows exceeding 5 retries (DX_OUTBOX_MAX_ATTEMPTS) transition to failed until manually retried via /api/latticeContextSync.
bash
docker compose -f infra/compose/prod.yml exec orion-ld curl -fsS http://127.0.0.1:1026/version
docker compose -f infra/compose/prod.yml logs --tail 80 mosquitto nodered

5. AI Providers, MCP Gateway, and Hybrid RAG ​

plugin-dxos-ai connects to upstream language models via AGENT_PROVIDER, AGENT_BASE_URL, and AGENT_MODEL, queries pgvector HNSW indexes sized to DX_EMBEDDING_DIM (1536), and exports OTel traces alongside latticeAiTraces.

Symptoms: MCP HTTP Blocks, Embedding Dimension Errors, or Dropped Traces ​

Root CauseVerification & Remediation
MCP HTTP tool blocked/api/dxos-mcp blocks outbound HTTP calls to internal addresses unless explicitly listed in DXOS_MCP_INTERNAL_HTTP_ALLOWLIST. Check the JSON-RPC error payload and latticeAiAuditLogs entries.
P.A.R.A. RAG dimension mismatchSwitching embedding models without matching DX_EMBEDDING_DIM (1536) causes pgvector index queries on latticeParaChunks to fail; re-index existing chunks when changing vector dimensions.
Missing traces in OTel CollectorInspect the otel object returned by /api/dxos:health. Rising exportFailures or a populated lastError indicates connectivity or endpoint mismatch on OTEL_EXPORTER_OTLP_ENDPOINT (http://otel-collector:4318) across the app network.
bash
# Inspect live OTel queue and export counters from /api/dxos:health
curl -fsS http://127.0.0.1:13000/api/dxos:health | jq '.data.otel // .otel'

6. Scoped API Keys (ldx_pat_*) and PKI Ledger ​

Headless integrations using latticeApiKeys and latticeCryptoLedger fail closed on scope mismatches, header role escalation, or key wrapping drift.

  1. HTTP 401/403 with ldx_pat_* tokens: Tokens follow ldx_pat_<8hex>_<32hex> and persist only a SHA-256 keyHash inside latticeApiKeys (which is blocked from generic REST reads by a private collection guard). Verify token expiration (expiresInDays bounded 1..365), required scopes (read, write, wms, dmn, iot, ai, ledger), and note that clampHeaderRole prevents escalating beyond the key's bound role.
  2. LEDGER_IMMUTABLE or QR signature mismatch: latticeCryptoLedger serializes per-organization appends with pg_advisory_xact_lock and rejects all UPDATE/DELETE operations. If /api/dxosWms:verifyTrackSignature fails after a migration or restore, verify that LATTICE_TRACK_VERIFY_SECRET and NOCOBASE_ENCRYPTION_FIELD_KEY match the environment that signed the original record.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)