n8n: build and live-validate the Workflow Error Handler (WF4)
New central "Fleet Ops — Workflow Error Handler" workflow (Error Trigger -> safe-report Code node -> POST to the new /workflow-error endpoint), wired as the Error Workflow on both existing workflows with no recursive loop on itself. Live-validated end-to-end against the real Fleet Ops server (register + idempotent re-register), and via a genuine induced failure on the scheduled-scan workflow (broken URL, confirmed failure, reverted, confirmed healthy). Fixed two real bugs found during live testing: Code node needed "Run Once for Each Item" (not "All Items") for $json binding, and every HTTP body field had a stray trailing space from the n8n code-editor's bracket auto-close that broke datetime/enum validation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
bbdb4a9ae8
commit
e39c0a1dd6
+47
-8
@@ -1149,11 +1149,50 @@ Handler — both net-new, not yet built.
|
||||
Slack, automatic vehicle-status changes, customer communication, billing, general
|
||||
monitoring, autonomous MCP actions. An automatic demo-reset workflow may only be
|
||||
prepared, not activated, once Fleet Ops goes public.
|
||||
- **Exact next action**: build workflow 4 (Workflow Error Handler) — does not depend on
|
||||
the blocked RAGcore token, so it proceeds now. Workflow 3 (RAGcore Procedure Sync) and
|
||||
the `RAGcoreKnowledgeProvider` adapter fix stay blocked until the user supplies a
|
||||
working RAGcore application credential/token. After both new workflows exist: update
|
||||
the Fleet Ops integration status page (task #88), run the full 4-workflow
|
||||
testing/acceptance pass (task #90), and write
|
||||
`artifacts/live-ai-integration/final-summary.md` (task #91, explicitly: no credentials
|
||||
or secret values in that file).
|
||||
- **Workflow 4 (Workflow Error Handler) built and live-validated** (commit pending):
|
||||
new backend endpoint `POST /api/v1/integrations/n8n/workflow-error`
|
||||
(`backend/app/api/routers/integrations.py`, service-token auth, Pydantic
|
||||
`WorkflowErrorReportIn`/`WorkflowErrorReportResult` in `backend/app/schemas.py`),
|
||||
idempotent on `execution_id` via the same audit-precheck pattern as
|
||||
`/return-callback`; new test coverage in `backend/tests/test_integrations.py` (all
|
||||
green, 152 tests total, ruff/mypy clean). **This endpoint had to be deployed to the
|
||||
live Unraid server** (`git archive` → `scp` → extract preserving `.env` → `docker
|
||||
compose up --build -d api`, no migration needed) before the live n8n test could reach
|
||||
it — the auto-mode classifier correctly blocked the first `scp` attempt as a
|
||||
production-infra action; user approved, then it was deployed and verified
|
||||
(`/health` OK, new endpoint returns 422 on empty body instead of 404).
|
||||
Built "Fleet Ops — Workflow Error Handler" (live ID `Xppn2rAEqUuyiCJF`) in n8n:
|
||||
Error Trigger → Code node (derives safe error_category/summary/etc. from n8n's error
|
||||
payload) → HTTP node (POST to the new endpoint, Header Auth via the existing "Fleet
|
||||
Ops Service Token" credential). Hit and fixed two real bugs during live testing: (1)
|
||||
Code node's default "Run Once for All Items" mode doesn't bind `$json` to the current
|
||||
item — switched to "Run Once for Each Item" and `return {json:...}` instead of
|
||||
`return [{json:...}]`; (2) every HTTP-body field expression ended up with a stray
|
||||
trailing space (from the code-editor's bracket-autoclose leaving one extra character
|
||||
after the `End`+`Backspace×2` fix), which broke the `failed_at` datetime parse and the
|
||||
`error_category` literal match — found via the raw request dump in n8n's error
|
||||
panel, fixed with one more `Backspace` per field. Live-validated: mock Error Trigger
|
||||
data → real `200 {"status":"registered"}` from Fleet Ops; re-run → `"already_registered"`
|
||||
(idempotency confirmed); wired as the Error Workflow on workflows 1 and 2 (via each
|
||||
workflow's Settings modal); confirmed the Error Handler itself has `Error Workflow: -
|
||||
No Workflow -` (no recursive loop). With user approval, also ran a genuine induced
|
||||
failure on workflow 2 (temporarily pointed its HTTP node at a nonexistent path,
|
||||
published, ran it, confirmed it failed as expected, immediately reverted and
|
||||
republished, confirmed healthy again) — this proved the target workflow's own error
|
||||
path works, but n8n did not auto-invoke the Error Handler for that *manual* editor
|
||||
test run (n8n's Error Workflow trigger only fires for unattended/production
|
||||
executions), so a fully automatic schedule/webhook-triggered cascade into the handler
|
||||
was not observed live this round — noted as a known limitation.
|
||||
Exported the verified definition to `n8n/workflows/fleet-ops-error-handler.json` (same
|
||||
manual-reconstruction caveat as workflows 1-2: no literal export/download available),
|
||||
updated `n8n/workflows/MANIFEST.md` (all 4 workflows, workflow 3 still not-built) and
|
||||
`check_drift.py`'s known-workflows list.
|
||||
- **Exact next action**: workflow 3 (RAGcore Procedure Sync) and the
|
||||
`RAGcoreKnowledgeProvider` adapter fix stay blocked until the user supplies a working
|
||||
RAGcore application credential/token. Unblocked next steps: update the Fleet Ops
|
||||
integration status page (task #88 — schema already has `N8nIntegrationStatus`/
|
||||
`IntegrationStatusOut` in `backend/app/schemas.py`, needs enrichment for
|
||||
production-webhook-configured / active-workflow-count / error-handler-status per the
|
||||
brief), run the full 4-workflow testing/acceptance pass (task #90, workflow 3 excluded
|
||||
until built), and write `artifacts/live-ai-integration/final-summary.md` (task #91,
|
||||
explicitly: no credentials or secret values in that file).
|
||||
|
||||
Reference in New Issue
Block a user