{"record":{"id":"5101972fd5d700b4","repo":"apple/pkl","slug":"cannotresolvetypeforprotobuf","errorCode":"cannotResolveTypeForProtobuf","errorMessage":"cannotResolveTypeForProtobuf","messagePattern":"cannotResolveTypeForProtobuf","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java","lineNumber":123,"sourceCode":"    }\n  }\n\n  public abstract static class renderType extends ExternalMethod1Node {\n    @SuppressWarnings(\"unused\")\n    @Specialization\n    protected String eval(VmTyped self, Object value) {\n      return renderType(value);\n    }\n  }\n\n  @TruffleBoundary\n  private static String renderType(Object value) {\n    var clazz =\n        value instanceof VmValue vmValue\n            ? vmValue.getVmClass()\n            : value instanceof TypeNode typeNode ? typeNode.getVmClass() : value.getClass();\n    if (clazz == null) {\n      throw new VmExceptionBuilder()\n          .evalError(\"cannotResolveTypeForProtobuf\")\n          .withProgramValue(\"Value\", value)\n          .build();\n    }\n    var name =\n        clazz instanceof VmClass vmClass\n            ? vmClass.getSimpleName()\n            : ((Class<?>) clazz).getSimpleName();\n\n    return fieldNameEscaper.escape(name);\n  }\n\n  @TruffleBoundary\n  private static ProtobufRenderer createRenderer(VmTyped self, StringBuilder builder) {\n    var indent = (String) VmUtils.readMember(self, Identifier.INDENT);\n\n    return new ProtobufRenderer(builder, indent, PklConverter.fromRenderer(self));\n  }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/protobuf/RendererNodes.java#L105-L141","documentation":"The Protobuf renderer could not determine the Pkl class of the value it is rendering — the resolved class came back null. Protobuf output requires a concrete type name to compute the protobuf message type, so rendering aborts.","triggerScenarios":"Calling the protobuf render entry point (`eval`) on a value whose class cannot be resolved: a VmValue/VmValue holder or TypeNode whose `getVmClass()` returns null, or an object with no concrete class.","commonSituations":"Rendering a null-class placeholder or synthetic value to protobuf; passing a type reference (TypeNode) that points at a class that failed to load or is undefined.","solutions":["Render a concrete typed object or Dynamic instance whose class is resolvable","Check that the type being referenced actually exists/imports correctly in the module","Use a different output format for values without concrete Pkl classes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasResolvableClass(v) { return v != null && resolveVmClass(v) != null; }","typeGuard":"const isProtobufRenderableValue = (v) => getVmClass(v) != null;","tryCatchPattern":"try { renderAsProtobuf(value) } catch (e) { if (e.code === 'cannotResolveTypeForProtobuf') { /* check type references/imports */ } else throw e }","preventionTips":["Render only concrete typed objects to protobuf","Verify all type references in the module resolve (no missing imports)","Avoid passing TypeNodes or null-class placeholders to renderers"],"tags":["pkl","protobuf","renderer","type-resolution"],"backgroundTag":"type-mismatch","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}