Skip to content

docgen from-shacl: node-shape names serialize as "[object Object]" since 0.6.14 (likely jsonld v8 → v9 bump) #369

@ddeboer

Description

@ddeboer

Summary

docgen from-shacl regressed in 0.6.14: named node-shape references (nodeShape.name, property.node, etc.) are now serialized as the literal string [object Object] in the framed JSON passed to the Liquid template, breaking any template that prints them.

The 0.6.14 release notes state “version bump only, no code changes,” but packages/docgen/package.json actually bumped runtime dependencies — most notably jsonld ^8.3.3 → ^9.0.0, and rdf-dereference ^4 → ^5. The behavior change tracks that bump.

This is not related to the frame-merging feature in #366 / 0.6.15 — the regression is identical in 0.6.14 and 0.6.15.

Reproduction

In netwerk-digitaal-erfgoed/schema-profile:

npx --yes --package=@lde/docgen@0.6.13 docgen from-shacl shacl.ttl ./assets/class-diagram.mmd.liquid > /tmp/v13.mmd
npx --yes --package=@lde/docgen@0.6.14 docgen from-shacl shacl.ttl ./assets/class-diagram.mmd.liquid > /tmp/v14.mmd
diff /tmp/v13.mmd /tmp/v14.mmd

Output:

6c6
<     class CreativeWork {
---
>     class [object Object] {
28c28
<     class MediaObject {
---
>     class [object Object] {
... (one diff per named node shape)

The class-diagram.mmd.liquid template uses {{ nodeShape.name }}. In 0.6.13 this prints CreativeWork; in 0.6.14+ it prints [object Object], which mmdc then refuses to parse:

Parse error on line 3:
...ection TB    class [object Object] {
----------------------^
Expecting 'ALPHA', 'NUM', 'MINUS', 'UNICODE_TEXT', 'BQUOTE_STR', got 'SQS'

The same [object Object] also appears anywhere a property points at an inline sh:node shape (e.g. **associatedMedia**: [object Object]), suggesting both symptoms share a single root cause: framed object references are now landing as JS objects in the template scope, where 0.6.13 delivered them as scalar strings.

Suspected cause

packages/docgen/src/parse.ts calls jsonld.fromRDF(nqString, { useNativeTypes: true }), and downstream frame.ts calls jsonld.frame(…). Between jsonld v8 → v9, framing/output shape for IRI-typed values and string literals tightened in ways that can change whether a value reaches the template as a primitive or as a wrapped { ‘@id’: … } / { ‘@value’: … } object. Liquid then stringifies the wrapper as [object Object].

Likely fixes (any one):

  • Pin jsonld back to ^8.3.3 until the framing change is understood.
  • Adjust the default frame in frame.ts so IRI/string fields are coerced (@type: ‘@id’, @type: ‘@vocab’, etc.) under jsonld v9 semantics.
  • Post-process the framed JSON before rendering, unwrapping single-key @id/@value objects to scalars for template consumption.

Impact

Any consumer using docgen from-shacl with a Liquid template that references node-shape names is broken on @latest. Confirmed in netwerk-digitaal-erfgoed/schema-profile (mermaid class diagram); likely affects other downstream specs.

Workaround

Pin @lde/docgen@0.6.13. (This still leaves the older inline-sh:node [object Object] bug for properties whose value is an inline shape, but at least restores class names and unblocks mmdc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions