apache/incubator-seata · error · Error
unknown di for element ${semantic.id}
Error message
unknown di for element ${semantic.id} What it means
Thrown by SagaImporter.add when a semantic element's style.Type is neither 'Node' nor 'Edge'. The importer only knows how to materialize shapes (Node) and connections (Edge); any other DI type is rejected with the element id.
Source
Thrown at saga/seata-saga-statemachine-designer/src/modeling/SagaImporter.js:278
source = attrs.source || this.getSource(semantic);
target = this.getTarget(semantic);
semantic.style.source = source;
semantic.style.target = target;
if (source && target) {
elementDefinition = elementData(semantic, {
source,
target,
waypoints,
});
element = elementFactory.createConnection(elementDefinition);
canvas.addConnection(element);
}
} else {
throw new Error(`unknown di for element ${semantic.id}`);
}
return element;
};
SagaImporter.prototype.getSource = function (semantic) {
return this.getShape(semantic.style.source);
};
SagaImporter.prototype.getTarget = function (semantic) {
return this.getShape(semantic.style.target);
};
SagaImporter.prototype.getShape = function (name) {
return this.elementRegistry.find((element) => element.businessObject.Name === name);
};
View on GitHub (pinned to e01f97c6db)
Solutions
- Inspect the JSON element with the reported id and check its style.Type value.
- Normalize style.Type to exactly 'Node' or 'Edge' (capital first letter) for every element before import.
- Remove unsupported element kinds (labels, groups) from the file and re-import.
- If the file came from another designer version, re-export it from a matching designer version.
Example fix
// before: { "id": "e1", "style": { "Type": "label", ... } }
// after: { "id": "e1", "style": { "Type": "Node", "bounds": { "x":100,"y":100,"width":80,"height":60 } } } Defensive patterns
Strategy: validation
Validate before calling
function hasKnownDiTypes(definitionsJson) {
const els = Object.values(definitionsJson.States || {}).concat(definitionsJson.edge ? [definitionsJson.edge] : []);
return els.every(el => el && (el.style.Type === 'Node' || el.style.Type === 'Edge'));
}
// run before importer.importDefinitions(definitionsJson) Type guard
function isSupportedDiType(style) {
return style != null && (style.Type === 'Node' || style.Type === 'Edge');
} Try / catch
eventBus.on('import.done', (event) => {
if (event.error && /unknown di for element/.test(event.error.message)) {
// report the offending element id and skip it; the importer already logs via console.error
}
}); Prevention
- Schema-validate imported JSON: style.Type must be exactly 'Node' or 'Edge'.
- Only load files produced by the matching designer version.
- Keep a canonical example state machine JSON and diff unknown files against it.
When it happens
Trigger: Importing a Seata state machine JSON whose style objects carry an unexpected Type value (e.g. 'Label', 'Group', a typo like 'node', or a missing Type causing undefined) via SagaImporter.importDefinitions.
Common situations: Hand-edited or machine-generated state machine JSON with wrong style.Type casing/values; files produced by a newer/older designer version with new element types; JSON exported from a different tool.
Related errors
- Two or more start states, ${target} and ${definitions.StartS
- Export failed: Unable to resolve source state '${source}' fo
- Unknown StateType[{value}]
- No JsonCodec provider found. Please add json-common-core to
- datasource required not null!
AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14).
Data as JSON: /api/errors/79b14a5667cfdf12.
Report an issue: GitHub.