Contract Node Table Integrity Validator Before Restore
Loading workflow…
Workflow Description
A self-contained workflow that inspects existing root+nodes reference tables without building them or restoring any graph. Per table it indexes ids and flags duplicates, validates the declared schema, records every dangling ref with source id, field path and missing target, computes unreachable nodes from the root via BFS, and detects self and multi-node cycles with an iterative Tarjan SCC while separating shared references. An If node routes on valid, two Set nodes render summaries, and a final Code node orders the merged reports.
How it works
- 1.Manual Trigger, then a Code node emits two fictional tables: a healthy one with an allowed cycle and a broken one with a dangling ref, duplicate id, unreachable nodes and a self cycle
- 2.Build the id index, exclude duplicate occurrences and list them in duplicateIds
- 3.Validate node type object/array and that fields is an object, collecting schema errors
- 4.Collect edges from {$ref:id} and record each dangling ref with source node id, field path and missing target id
- 5.Run BFS from the root to compute unreachableNodeIds without deleting any node
- 6.Detect cycles with an iterative Tarjan SCC, distinguishing self from multi-node cycles, and record sharedRefs
- 7.Route on valid with If, emit status and summary with two Set nodes, append with Merge, then order reports in a final Code node
Use cases
- Validate a reference table before handing it to an object-graph restore algorithm
- Audit tables produced by an earlier encoding stage before restore
- Screen large node tables for duplicate ids, dangling refs and orphan nodes
Requirements
- n8n 2.48.7 with Manual Trigger, Code, If, Set and Merge nodes
- Declared-schema table: string root and nodes array of {id,type,fields}
- References as single-field {$ref:id} objects
- No credentials or external connections; the flow makes no network calls
Setup and testing in n8n
- Import the workflow and execute Manual Trigger
- Confirm the final output has two items: t1-healthy with valid=true/status=valid and t2-broken with valid=false and error lists
- Confirm t2-broken reports duplicateIds=[n3], dangling ref at path missing to nX, unreachableNodeIds=[n3,n4,n5] and two cycles
- Edge case: set root='ghost' in a sample and confirm ROOT_TARGET_MISSING names the missing id
- Edge case: delete the table field from an item and confirm INPUT_MISSING with nodeCount=0
Service Value
Ready-made workflow template for automation delivery and service execution.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (8)
Manual Trigger
Manual Trigger
Emit Sample Node Tables
Code
Validate Reference Table
Code
Is Table Valid
If
Valid Table Summary
Set
Invalid Table Report
Set
Merge Report Branches
Merge
Collect Integrity Reports
Code
Stage 1 - Sample Tables
Sticky Note
Stage 2 - Validator
Sticky Note
Stage 3 - Routing and Report
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides