apple/pkl · error · VmException

invalidModuleOutput

invalidModuleOutput

Error message

invalidModuleOutput

What it means

Sentinel error 'invalidModuleOutput' in EvaluatorImpl.evaluateOutputValueAs: after forcing the module's `output.value`, the value's PClassInfo does not match the classInfo requested by the caller, so the result cannot be returned as the expected type. The input at fault is a module whose output.value is not an instance of the requested PClassInfo.

Solutions

  1. Make the module's output.value conform to the requested type (check the class in the Pkl source).
  2. Request the correct PClassInfo matching what the module actually outputs.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java:331 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkl-core/src/main/java/org/pkl/core/EvaluatorImpl.java:331

  @Override
  public <T> T evaluateOutputValueAs(ModuleSource moduleSource, PClassInfo<T> classInfo) {
    return doEvaluate(
        moduleSource,
        (module) -> {
          var output = VmUtils.readModuleOutput(module);
          var value = VmUtils.readMember(output, Identifier.VALUE);
          var valueClassInfo = VmUtils.getClass(value).getPClassInfo();
          if (valueClassInfo.equals(classInfo)) {
            if (value instanceof VmValue vmValue) {
              vmValue.force(false);
              //noinspection unchecked
              return (T) vmValue.export();
            }
            //noinspection unchecked
            return (T) value;
          }
          throw moduleOutputValueTypeMismatch(module, classInfo, value, output);
        });
  }

  @Override
  public void close() {
    // if currently executing, blocks until cancellation has completed (see
    // https://github.com/oracle/graal/issues/1230)
    polyglotContext.close(true);
    try {
      packageResolver.close();
    } catch (IOException ignored) {
    }

    if (timeoutExecutor != null) {
      timeoutExecutor.shutdown();
    }
  }

View on GitHub (pinned to f3efcbfc9b)