Bug Report 🐛
@mttrbrts , @dselman As asked in the last workgroup meeting I am opening this issue describing the errors I came across while testing concerto-v4 on markdown-transform.
While I was testing template-engine against Concerto v4, I encountered consistent runtime crashes. The root cause traces back to the ASTs generated by markdown-transform.
Concerto v4 introduces strict array enforcement. If a property is defined in the metamodel as an array (e.g., the nodes property in CommonMark/TemplateMark elements), v4 strictly demands that the property exists and is an array, even if it is empty (nodes: []).
Currently, markdown-transform is "lazy" in its AST generation—if a markdown element has no children, it either omits the nodes property entirely or leaves it as undefined. When this AST is passed up the stack, the v4 engine's strict runtime validation rejects it and crashes the execution.
Error Message
ValidationException: Expected property 'nodes' to be an array
Steps to Reproduce
- Initialize a Concerto v4 engine with the standard CommonMark/TemplateMark metamodels.
- Use
markdown-transform to parse a valid markdown string that results in leaf nodes or blocks without child elements.
- Pass the resulting JSON AST into the Concerto v4 validator.
- The v4 engine will throw a
ValidationException at runtime due to the missing nodes arrays.
Impact
This is currently a hard blocker for upgrading template-engine, cicero, and downstream applications (like APAP) to Concerto v4.
Proposed Solutions for Discussion
We have a few potential paths to resolve this, and I'd love your architectural guidance on which direction to take:
- Parser Update: Update the core parsing logic within
markdown-transform to guarantee nodes: [] is always instantiated for elements that require it.
- Recursive AST Patch (Post-Processing): Introduce a sanitization utility that recursively walks the AST immediately after parsing, forcefully injecting
nodes: [] wherever the metamodel demands it (we have a local script successfully doing this to bypass the errors).
- Metamodel Relaxation: Update the underlying Concerto metamodel for CommonMark to make the
nodes array optional, though this might conflict with the design philosophy of v4's strictness.
Let me know which approach aligns best with the v4 roadmap, and I'd be happy to spearhead the PR for it!
Bug Report 🐛
@mttrbrts , @dselman As asked in the last workgroup meeting I am opening this issue describing the errors I came across while testing concerto-v4 on markdown-transform.
While I was testing
template-engineagainst Concerto v4, I encountered consistent runtime crashes. The root cause traces back to the ASTs generated bymarkdown-transform.Concerto v4 introduces strict array enforcement. If a property is defined in the metamodel as an array (e.g., the
nodesproperty in CommonMark/TemplateMark elements), v4 strictly demands that the property exists and is an array, even if it is empty (nodes: []).Currently,
markdown-transformis "lazy" in its AST generation—if a markdown element has no children, it either omits thenodesproperty entirely or leaves it asundefined. When this AST is passed up the stack, the v4 engine's strict runtime validation rejects it and crashes the execution.Error Message
Steps to Reproduce
markdown-transformto parse a valid markdown string that results in leaf nodes or blocks without child elements.ValidationExceptionat runtime due to the missingnodesarrays.Impact
This is currently a hard blocker for upgrading
template-engine,cicero, and downstream applications (like APAP) to Concerto v4.Proposed Solutions for Discussion
We have a few potential paths to resolve this, and I'd love your architectural guidance on which direction to take:
markdown-transformto guaranteenodes: []is always instantiated for elements that require it.nodes: []wherever the metamodel demands it (we have a local script successfully doing this to bypass the errors).nodesarray optional, though this might conflict with the design philosophy of v4's strictness.Let me know which approach aligns best with the v4 roadmap, and I'd be happy to spearhead the PR for it!