Skip to content

[Bug] Concerto v4 Compatibility: Missing 'nodes' array in AST causes ValidationException #651

@rockaxorb13

Description

@rockaxorb13

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

  1. Initialize a Concerto v4 engine with the standard CommonMark/TemplateMark metamodels.
  2. Use markdown-transform to parse a valid markdown string that results in leaf nodes or blocks without child elements.
  3. Pass the resulting JSON AST into the Concerto v4 validator.
  4. 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:

  1. Parser Update: Update the core parsing logic within markdown-transform to guarantee nodes: [] is always instantiated for elements that require it.
  2. 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).
  3. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions