n8n: checked against a live instance; archived workflows left out

Inspect on a real n8n showed the workflow and run lists answer as the reader expects, with nothing empty. Workflows marked isArchived are no longer listed or counted. Test and INTEGRATIONS.md updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-17 19:05:46 +01:00
1 parent 386d77b351
commit 01fb5d6335
3 files changed
+11 -5

No files matched your search

+5 -4
View File
@@ -4,8 +4,8 @@
* Reading only: the workflows (and which are switched on), and the most recent runs, from which each workflow's **last run** and how many runs failed in the last day are worked out —
* an automation that has been failing since Tuesday is what is worth hearing about. Nothing is sent to n8n but GET requests for these.
*
* Endpoints and field names are from n8n's published public API (`/api/v1/workflows`, `/api/v1/executions`) and have not been checked against a live server here; every field is
* read defensively. Only the newest 250 runs are looked at, so a workflow that runs more rarely than that many other runs may show no run.
* Endpoints and field names are from n8n's published public API (`/api/v1/workflows`, `/api/v1/executions`) and were checked against a live server (Inspect: every field the reader
* uses had a value); every field is still read defensively. Only the newest 250 runs are looked at, so a workflow that runs more rarely than that many other runs may show no run.
*/
import { requestJson } from "../httpJson.js";
import { withDiagLogging } from "../../services/diagLog.js";
@@ -48,13 +48,14 @@ const iso = (v: unknown): string | null => {
export const FAILED_STATUSES = new Set(["error", "crashed"]);
const PAGES = 4;
/** Pure: the workflows of one page. */
/** Pure: the workflows of one page, archived ones left out. */
export function parseWorkflows(raw: unknown): { id: string; name: string; active: boolean }[] {
const out: { id: string; name: string; active: boolean }[] = [];
for (const item of Array.isArray(obj(raw).data) ? (obj(raw).data as unknown[]) : []) {
const w = obj(item);
const id = str(w.id);
if (!id) continue;
// An archived workflow is out of the way in n8n (and never active): it isn't one to list or count.
if (!id || w.isArchived === true) continue;
out.push({ id, name: str(w.name) ?? id, active: w.active === true });
}
return out;
+5
View File
@@ -51,6 +51,11 @@ describe("what n8n's API says", () => {
assert.deepEqual(adapter.parseWorkflows(null), []);
});
test("an archived workflow (n8n marks it isArchived) is left out", () => {
const w = adapter.parseWorkflows({ data: [{ id: "a", name: "Live", active: true, isArchived: false }, { id: "b", name: "Put away", active: false, isArchived: true }] });
assert.deepEqual(w, [{ id: "a", name: "Live", active: true }]);
});
test("each workflow's last outcome is the newest finished run; a run still going is not an outcome; failures are counted for the last day", () => {
const workflows = [{ id: "1", name: "A", active: true }, { id: "2", name: "B", active: true }, { id: "3", name: "C", active: false }];
const runs = {