{"record":{"id":"012b6e9c7c244158","repo":"apple/pkl","slug":"values-of-type-typealias-cannot-be-rendered-as-y","errorCode":null,"errorMessage":"Values of type `TypeAlias` cannot be rendered as YAML. Value: %s","messagePattern":"Values of type `TypeAlias` cannot be rendered as YAML\\. Value: (.+?)","errorType":"exception","errorClass":"RendererException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/YamlRenderer.java","lineNumber":210,"sourceCode":"      doVisitProperties(value.getProperties());\n    }\n\n    @Override\n    public void visitModule(PModule value) {\n      doVisitProperties(value.getProperties());\n    }\n\n    @Override\n    public void visitClass(PClass value) {\n      throw new RendererException(\n          String.format(\n              \"Values of type `Class` cannot be rendered as YAML. Value: %s\",\n              value.getSimpleName()));\n    }\n\n    @Override\n    public void visitTypeAlias(TypeAlias value) {\n      throw new RendererException(\n          String.format(\n              \"Values of type `TypeAlias` cannot be rendered as YAML. Value: %s\",\n              value.getSimpleName()));\n    }\n\n    @Override\n    public void visitNull() {\n      emitter.emit(YamlUtils.plainScalar(\"null\", Tag.NULL));\n    }\n\n    @Override\n    public void visitRegex(Pattern value) {\n      throw new RendererException(\n          String.format(\"Values of type `Regex` cannot be rendered as YAML. Value: %s\", value));\n    }\n\n    private void doVisitIterable(Iterable<?> iterable, @Nullable String tag) {\n      emitter.emit(","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/YamlRenderer.java#L192-L228","documentation":"Pkl's YAML renderer (YamlRenderer) only knows how to serialize concrete Pkl values (objects, lists, primitives) to YAML. When the value being rendered is a TypeAlias — a named alias for another type rather than a runtime value — there is no valid YAML representation, so visitTypeAlias throws a RendererException. This is a defensive guard: the renderer is being asked to output something that is a type-level, not value-level, entity.","triggerScenarios":"Passing a reference to a Pkl type alias (or a module/class/type-alias object) into YAML rendering, e.g. rendering a property whose value is a type alias instead of an instance, or calling the renderer/YAML emitter on non-data values like `Int`-style aliases.","commonSituations":"Config mistakes where a pkl property was declared with a type alias but assigned the alias itself instead of a value; tooling that walks a module and renders every declared member as YAML; dynamic code that resolved a module member by name and got the alias object rather than an instance.","solutions":["Find the property/expression whose value is a TypeAlias and replace it with an actual value of that type (e.g. instantiate the aliased type).","If you intend to render type metadata, render its name/text instead of the alias object itself (e.g. value.getSimpleName() or a String property).","Filter out non-value members (classes, type aliases, modules) before feeding values to the YAML renderer.","Check whether a lookup by name picked the wrong module member (alias vs. instance) and disambiguate."],"exampleFix":"// before (Pkl)\noutputText = renderer.renderDocument(myAlias)\n// after\noutputText = renderer.renderDocument(myValue) // an instance conforming to the alias, not the alias itself","handlingStrategy":"validation","validationCode":"// Kotlin/Java caller\nif (value is org.pkl.core.runtime.VmValue && value.getVmClass() is VmTypeAlias) {\n  throw IllegalArgumentException(\"Cannot render type alias ${value.getVmClass().getSimpleName()} as YAML\")\n}","typeGuard":"fun isRenderableValue(v: Any?): Boolean = when (v) {\n  null, is String, is Boolean, is Number, is List<*>, is Map<*, *> -> true\n  else -> v is org.pkl.core.runtime.VmValue && v.getVmClass() !is VmTypeAlias && v.getVmClass() !is VmClass\n}","tryCatchPattern":null,"preventionTips":["Only pass concrete data values (objects, lists, scalars) to the YAML renderer.","Filter out module-level declarations (classes, type aliases) before rendering.","Resolve aliases to their underlying values before output."],"tags":["yaml","renderer","type-alias","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}