{"record":{"id":"722fb941134d9406","repo":"apple/pkl","slug":"values-of-type-regex-cannot-be-rendered-as-prope","errorCode":null,"errorMessage":"Values of type `Regex` cannot be rendered as Properties. Value: %s","messagePattern":"Values of type `Regex` cannot be rendered as Properties\\. Value: (.+?)","errorType":"exception","errorClass":"RendererException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java","lineNumber":185,"sourceCode":"\n    @Override\n    public String convertTypeAlias(TypeAlias value) {\n      throw new RendererException(\n          String.format(\n              \"Values of type `TypeAlias` cannot be rendered as Properties. Value: %s\",\n              value.getSimpleName()));\n    }\n\n    @Override\n    public String convertRegex(Pattern value) {\n      throw new RendererException(\n          String.format(\n              \"Values of type `Regex` cannot be rendered as Properties. Value: %s\", value));\n    }\n\n    @Override\n    public String convertReference(Reference value) {\n      throw new RendererException(\n          String.format(\n              \"Values of type `Reference` cannot be rendered as Properties. Value: %s\", value));\n    }\n\n    private void doVisitMap(@Nullable String keyPrefix, Map<?, ?> map) {\n      for (Map.Entry<?, ?> entry : map.entrySet()) {\n        doVisitKeyAndValue(keyPrefix, entry.getKey(), entry.getValue());\n      }\n    }\n\n    private void doVisitKeyAndValue(@Nullable String keyPrefix, Object key, Object value) {\n      if (omitNullProperties && value instanceof PNull) return;\n\n      var keyString = keyPrefix == null ? convert(key) : keyPrefix + \".\" + convert(key);\n\n      if (value instanceof Composite composite) {\n        doVisitMap(keyString, composite.getProperties());\n      } else if (value instanceof Map<?, ?> map) {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/PropertiesRenderer.java#L167-L203","documentation":"The Properties renderer also rejects Pkl Regex values; the .properties format has no way to express a regex literal, so convertRegex throws a RendererException. Similarly convertReference rejects Reference values. Both are thrown eagerly during property traversal.","triggerScenarios":"Rendering output as `properties` when the value tree contains a Regex value (a `Regex(...)` pattern) or a lazily-referenced Reference value.","commonSituations":"Config files that define regex validation patterns (e.g. `pattern = Regex(\"[a-z]+\")`) exported to .properties for a legacy Java consumer; switching an existing output renderer from json to properties without auditing value types.","solutions":["Store the pattern as its String source in the config (`pattern: String = \"[a-z]+\"`) and build Regex at the consumer","Convert the Regex to its string representation before rendering to properties","Pick a format that supports regex values (json, pkl) instead of properties"],"exampleFix":"// before (Pkl)\npattern = Regex(\"[a-z]+\")\n// after (Pkl)\npattern = \"[a-z]+\" // build Regex on the consumer side","handlingStrategy":"validation","validationCode":"// Pkl-side: declare pattern as String\npattern: String = \"[a-z]+\"","typeGuard":null,"tryCatchPattern":"try {\n  renderer.render(value);\n} catch (RendererException e) {\n  // convert Regex values to their string source or switch output format\n}","preventionTips":["Store regexes as Strings in configs; construct Regex at the consumer","Audit value types before selecting the properties renderer","Keep properties output limited to primitive scalar values"],"tags":["properties","rendering","pkl","regex"],"backgroundTag":"unsupported-operation","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"}