elsa-workflows/elsa-core · error · InvalidOperationException
Source label ' ' not found in flowchart
Error message
Source label '{connNode.Source}' not found in flowchart What it means
CompileFlowchartAsync builds a label-to-activity map for the flowchart's activities, then resolves each connection's endpoints through that map; a connection whose Source label is missing throws InvalidOperationException. Every flowchart connection must reference a label defined by an activity in the same flowchart.
Solutions
- Fix the connection's source label to exactly match a label of an activity in the flowchart.
- Ensure each referenced activity is declared inside the flowchart block with the expected label.
- Remove stale connections after renaming or deleting activities.
- Catch the exception during compilation and flag the unknown label in the editor.
Example fix
// before
flowchart {
a: Log("start");
connect a -> b; // no activity labeled 'b' yet
}
// after
flowchart {
a: Log("start");
b: Log("end");
connect a -> b;
} Defensive patterns
Strategy: validation
Validate before calling
const labels = new Set(flowchart.activities.map(a => a.label)); const bad = flowchart.connections.filter(c => !labels.has(c.source)); if (bad.length) throw new Error('Unknown source labels: ' + bad.map(b => b.source).join(', ')); Type guard
function sourcesResolved(flowchart) { const labels = new Set(flowchart.activities.map(a => a.label)); return flowchart.connections.every(c => labels.has(c.source)); } Try / catch
try { await compileScript(script); } catch (InvalidOperationException ex) when (ex.Message.StartsWith('Source label')) { highlightUnknownLabel(ex); } Prevention
- Validate all connection labels against declared flowchart activities before compiling.
- Regenerate/update connections whenever activities are renamed or removed.
- Keep connections and activity declarations in the same flowchart block.
When it happens
Trigger: A FlowchartNode whose Connections list contains a connection with connNode.Source not present in labelToActivity — i.e. the source label does not match any activity's label in the flowchart.
Common situations: Typo in the source label in the connection declaration, an activity removed/renamed while connections still reference the old label, or the activity with that label declared outside this flowchart block.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Target label ' ' not found in flowchart
- Statement type is not supported
- Activity ' ' not found in registry
- Property ' ' not found on activity type
- Variable ' ' is not declared. Use 'var ' to declare a new…
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/39246dd0acceb722.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs:385
}
// Compile all labeled activities and build a label-to-activity map
var labelToActivity = new Dictionary<string, IActivity>();
foreach (var labeledNode in flowchart.Activities)
{
var activity = await CompileStatementAsync(labeledNode.Activity, cancellationToken);
if (activity != null)
{
labelToActivity[labeledNode.Label] = activity;
}
}
// Create connections
var connections = new List<Connection>();
foreach (var connNode in flowchart.Connections)
{
if (!labelToActivity.TryGetValue(connNode.Source, out var sourceActivity))
throw new InvalidOperationException($"Source label '{connNode.Source}' not found in flowchart");
if (!labelToActivity.TryGetValue(connNode.Target, out var targetActivity))
throw new InvalidOperationException($"Target label '{connNode.Target}' not found in flowchart");
var source = new Endpoint(sourceActivity, connNode.Outcome);
var target = new Endpoint(targetActivity);
connections.Add(new Connection(source, target));
}
// Create flowchart activity
var flowchartActivity = new Workflows.Activities.Flowchart.Activities.Flowchart
{
Activities = labelToActivity.Values.ToList(),
Connections = connections
};
// Set entry point if specified
if (!string.IsNullOrEmpty(flowchart.EntryPoint))View on GitHub (pinned to fe9217bdfa)