apple/pkl · error · VmException

cannotRenderType

cannotRenderType

Error message

cannotRenderType

What it means

The XML property list (PList) renderer cannot encode Pkl Duration values — the plist format has no duration type. visitDuration throws cannotRenderType naming the type `Duration` and target format `XML property list`, with the value attached for debugging. Use plist-supported types (String, Int, Double, Boolean, Data, Date) instead.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/stdlib/base/PListRendererNodes.java:110

      } else {
        builder.append(value);
      }

      builder.append("</real>");
    }

    @Override
    public void visitBoolean(Boolean value) {
      if (value) {
        builder.append("<true/>");
      } else {
        builder.append("<false/>");
      }
    }

    @Override
    public void visitDuration(VmDuration value) {
      throw new VmExceptionBuilder()
          .evalError("cannotRenderType", "Duration", "XML property list")
          .withProgramValue("Value", value)
          .build();
    }

    @Override
    public void visitDataSize(VmDataSize value) {
      throw new VmExceptionBuilder()
          .evalError("cannotRenderType", "DataSize", "XML property list")
          .withProgramValue("Value", value)
          .build();
    }

    @Override
    public void visitBytes(VmBytes value) {
      builder.append("<data>");
      builder.append(value.base64());
      builder.append("</data>");

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Convert the Duration to a plist-safe representation before rendering, e.g. `value.value` (seconds as Double) or `value.toUnit(Unit.s)`.
  2. Store the duration as a String (`"5.min"`) or plain number of seconds in the rendered object.
  3. Restructure output so Duration fields live outside the plist-rendered portion.
  4. Choose a different output renderer (YAML/JSON) if plist is not required.

Example fix

// before
output { renderer = new PListRenderer {}; value { timeout = 30.s } }

// after
output { renderer = new PListRenderer {}; value { timeoutSeconds = 30 } }
Defensive patterns

Strategy: validation

Validate before calling

// plist only supports scalars/strings/data/date
function plistSafeDuration(d: Duration) = d.toUnit(Unit.s).value

Try / catch

try { renderPlist(value) } catch (e) { if (e.message.contains('cannotRenderType') && e.message.contains('Duration')) renderPlist(convertDurations(value)) else throw e }

Prevention

When it happens

Trigger: Rendering output with a PListRenderer (xml plist) when the rendered value graph contains a VmDuration, e.g. `timeout = 5.min` reached from output.value.

Common situations: Config values that changed from numeric seconds to Duration during a refactor; passing through library-defined settings objects that include durations; generating Apple plist config files from Pkl settings containing timeouts/intervals.

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/7fae1d174881e677. Report an issue: GitHub.