{"record":{"id":"c43bf18eb8451c94","repo":"apple/pkl","slug":"error-converting-property-s-in-pkl-object-of-ty","errorCode":null,"errorMessage":"Error converting property `%s` in Pkl object of type `%s` to equally named constructor parameter in Java class `%s`: %s","messagePattern":"Error converting property `(.+?)` in Pkl object of type `(.+?)` to equally named constructor parameter in Java class `(.+?)`: (.+?)","errorType":"exception","errorClass":"ConversionException","httpStatus":null,"severity":"error","filePath":"pkl-config-java/src/main/java/org/pkl/config/java/mapper/PObjectToDataObject.java","lineNumber":211,"sourceCode":"                      + \"%nMissing Pkl property : %s\"\n                      + \"%nActual Pkl properties: %s\",\n                  value.getClassInfo(), targetType.getTypeName(), param.first, properties.keySet());\n          throw new ConversionException(message);\n        }\n\n        try {\n          var cachedPropertyType = cachedPropertyTypes[i];\n          if (!cachedPropertyType.isExactClassOf(property)) {\n            cachedPropertyType = PClassInfo.forValue(property);\n            cachedPropertyTypes[i] = cachedPropertyType;\n            cachedConverters[i] = valueMapper.getConverter(cachedPropertyType, param.second);\n          }\n          var cachedConverter = cachedConverters[i];\n          assert cachedConverter != null;\n          args[i] = cachedConverter.convert(property, valueMapper);\n          i += 1;\n        } catch (ConversionException e) {\n          throw new ConversionException(\n              String.format(\n                  \"Error converting property `%s` in Pkl object of type `%s` \"\n                      + \"to equally named constructor parameter in Java class `%s`: \"\n                      + e.getMessage(),\n                  param.first,\n                  value.getClassInfo(),\n                  Reflection.toRawType(targetType).getTypeName()),\n              e.getCause());\n        }\n      }\n\n      try {\n        @SuppressWarnings(\"unchecked\")\n        var result = (T) constructorHandle.invokeWithArguments(args);\n        return result;\n      } catch (Throwable t) {\n        throw new ConversionException(\n            String.format(\"Error invoking constructor `%s`.\", constructorHandle), t);","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-config-java/src/main/java/org/pkl/config/java/mapper/PObjectToDataObject.java#L193-L229","documentation":"This is a wrapping error: while converting each Pkl property to its corresponding Java constructor parameter, the per-property converter threw a ConversionException. pkl-config-java re-throws it with context identifying which property, Pkl type, and Java class failed, appending the original message; the root cause is available via getCause.","triggerScenarios":"Converter.convert on a Pkl Composite where a nested property's value cannot be converted to the matching constructor parameter type — e.g. a String that fails enum conversion, a Int that overflows the Java type, an unexpected null, or any nested ConversionException from a child converter (see errors 28/29).","commonSituations":"Config file contains a value of the wrong type for one field (e.g. string \"8080\" where an Int is expected); nested objects failing conversion deep in a hierarchy; enum strings not matching Java enum constants; version drift between Pkl schema and Java types.","solutions":["Fix the offending property value in the Pkl source so it matches the Java parameter type (the message names the exact property and Pkl type).","Inspect the nested cause (e.getCause()) for the underlying conversion failure details.","Check the Pkl schema type for that property against the Java constructor parameter type and regenerate/adjust the Java class if the schema changed.","Register a custom Converter for the problematic type if the default mapping is unsuitable."],"exampleFix":"// before: type mismatch in config\nserver { port = \"8080\" } // String, but Java expects int\n\n// after\nserver { port = 8080 }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return converter.convert(pklObject, valueMapper);\n} catch (ConversionException e) {\n  if (e.getMessage().startsWith(\"Error converting property\")) {\n    logger.error(\"Config property conversion failed: \" + e.getMessage());\n    throw new ConfigLoadException(e.getMessage(), e.getCause());\n  }\n  throw e;\n}","preventionTips":["Validate config values against the Pkl schema before mapping (evaluate the module first)","Keep Pkl property types aligned with Java constructor parameter types","Check getCause() for the underlying per-property failure","Register custom Converters for types where default mapping is lossy"],"tags":["config-mapping","type-mismatch","wrapped-exception","java","pkl"],"backgroundTag":"config-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"}