apple/pkl · error · VmException

elementNotSupportedHere

elementNotSupportedHere

Error message

elementNotSupportedHere

What it means

When rendering XML, a `Dynamic` object that was recognized as an XML element (or inline value) appeared in a position where the renderer does not support it. The renderer throws `elementNotSupportedHere` with the offending value instead of emitting invalid XML.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java:183

    @Override
    public void visitPair(VmPair value) {
      cannotRenderTypeAddConverter(value);
    }

    @Override
    public void visitRegex(VmRegex value) {
      cannotRenderTypeAddConverter(value);
    }

    @Override
    public void visitIntSeq(VmIntSeq value) {
      cannotRenderTypeAddConverter(value);
    }

    @Override
    protected void startDynamic(VmDynamic value) {
      if (isXmlElement(value)) {
        throw new VmExceptionBuilder()
            .evalError("elementNotSupportedHere")
            .withProgramValue("Value", value)
            .build();
      }
    }

    @Override
    public void startTyped(VmTyped value) {
      if (isXmlInline(value)) {
        throw new VmExceptionBuilder()
            .evalError("inlineNotSupportedHere")
            .withProgramValue("Value", value)
            .build();
      }
    }

    // No-op for XML
    @Override

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Move the element-shaped Dynamic into a position rendered as XML content (e.g. a `content` Listing)
  2. If it is data, not XML, rename its `name` member or use a plain object so it is not detected as an XmlElement
  3. Render only scalar values in attribute positions
  4. Check the pkl-xml library version and supported nesting rules

Example fix

// before
person { name = xmlElement("a", ...) }  // element in attribute position
// after
person { content { xmlElement("a", ...) } }
Defensive patterns

Strategy: validation

Validate before calling

// Pkl: only place XmlElement-shaped objects where the renderer starts elements
function looksLikeElement(d: Dynamic): Boolean = d.hasProperty("name") && d.hasProperty("content")

Type guard

function isScalar(v: Any): Boolean = v is String || v is Boolean || v is Number || v is Null

Prevention

When it happens

Trigger: A `Dynamic` value satisfying `isXmlElement` (has `name`/`attributes`/`content` members) is visited at a position in the XML output where an element cannot be started, e.g. as an attribute value or inside a property that is not rendered as element content.

Common situations: See trigger scenarios.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/3e111e149e89efba. Report an issue: GitHub.