{"record":{"id":"0a99d83e14334fb5","repo":"apple/pkl","slug":"undefinedpropertyvalue","errorCode":"undefinedPropertyValue","errorMessage":"undefinedPropertyValue","messagePattern":"undefinedPropertyValue","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java","lineNumber":53,"sourceCode":"      SourceSection sourceSection, Identifier propertyName, @Nullable PropertyTypeNode typeNode) {\n    super(sourceSection);\n    this.propertyName = propertyName;\n    this.typeNode = typeNode;\n  }\n\n  public boolean isUndefined(VirtualFrame frame) {\n    return typeNode == null || typeNode.getDefaultValue(frame) == null;\n  }\n\n  @Override\n  public Object executeGeneric(VirtualFrame frame) {\n    if (typeNode != null) {\n      var defaultValue = typeNode.getDefaultValue(frame);\n      if (defaultValue != null) return defaultValue;\n    }\n\n    CompilerDirectives.transferToInterpreter();\n    throw exceptionBuilder()\n        .undefinedPropertyValue(propertyName, VmUtils.getReceiver(frame))\n        .build();\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":58,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/member/DefaultPropertyBodyNode.java#L35-L58","documentation":"Pkl throws undefinedPropertyValue when a property's value is evaluated but no concrete value exists: the property has no body/expression and its type (or enclosing class/module) supplies no default value. DefaultPropertyBodyNode.executeGeneric first tries the type node's default; when that is null it raises undefinedPropertyValue naming the property and receiver. In effect, the property is declared but never assigned anything Pkl can compute.","triggerScenarios":"Accessing a property declared with a type but no value (e.g. `port: Int`) whose type has no default; a parent class/module property left undefined and not overridden; evaluating a listing/mapping element slot never filled; a required property omitted in an `new` expression without a default.","commonSituations":"Config consumers reading a field the author assumed someone else would set; new Pkl users writing type-only declarations expecting implicit defaults; a base template leaving properties abstract and the child forgetting to define them; removing a default from a type during refactoring.","solutions":["Assign a concrete value to the named property at the reported location.","Provide a default in the class/module (`port: Int = 8080`) so instances inherit it.","Set the property in the `new` expression or the extending module.","If the property must stay unset for now, guard readers with `x?.property != null` checks before use."],"exampleFix":"// before\nserver {\n  port: Int  // no value, no default\n}\n\n// after\nserver {\n  port: Int = 8080\n}","handlingStrategy":"validation","validationCode":"// Before consuming a rendered config, check required properties are defined:\n// e.g. in a test:\n// if (config.port == null) throw \"port is not set\"\n// Or in Pkl itself: `port: Int = 8080` provides a default.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every typed property a default value unless it is intentionally abstract.","Treat type-only declarations (`port: Int`) as abstract — always override them downstream.","Render the full config with pkl eval/tests to surface undefined properties early.","Keep a list of required fields and assert them in a test module."],"tags":["pkl","property","undefined-value","evaluation"],"backgroundTag":"missing-required-config-field","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"}