{"record":{"id":"6f66e3908656739c","repo":"apple/pkl","slug":"cannotfindpropertyinobjectnohint","errorCode":"cannotFindPropertyInObjectNoHint","errorMessage":"Cannot find property `{0}` in object of type `{1}`.","messagePattern":"Cannot find property `(.+?)` in object of type `(.+?)`\\.","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java","lineNumber":94,"sourceCode":"          ErrorMessages.create(\"cannotReferenceExternalProperty\", propertyName, err.getType());\n      case DEFAULT_MEMBER ->\n          ErrorMessages.create(\n              \"cannotReferenceDefaultProperty\",\n              ((PType.Class) err.getType()).getPClass().getSimpleName());\n      case EXTERNAL_CLASS ->\n          ErrorMessages.create(\n              \"cannotReferencePropertyInExternalClass\", propertyName, err.getType());\n    };\n  }\n\n  @Specialization\n  protected VmReference evalReference(VmReference receiver) {\n    assert lookupMode == MemberLookupMode.EXPLICIT_RECEIVER;\n    try {\n      return receiver.withPropertyAccess(propertyName);\n    } catch (VmReferenceAccessError err) {\n      CompilerDirectives.transferToInterpreter();\n      throw exceptionBuilder()\n          .evalError(\"cannotFindPropertyInObjectNoHint\", propertyName, receiver.exportType())\n          .withHint(getReferenceErrorHint(receiver, err))\n          .build();\n    }\n  }\n\n  // This method effectively covers `VmObject receiver` but is implemented in a more\n  // efficient way. See:\n  // https://www.graalvm.org/22.0/graalvm-as-a-platform/language-implementation-framework/TruffleLibraries/#strategy-2-java-interfaces\n  @Specialization(guards = \"receiver.getClass() == cachedClass\", limit = \"99\")\n  protected Object evalObject(\n      Object receiver,\n      @Cached(\"getVmObjectSubclassOrNull(receiver)\") Class<? extends VmObjectLike> cachedClass,\n      @Cached(\"create()\") IndirectCallNode callNode) {\n\n    var object = cachedClass.cast(receiver);\n    checkConst(object);\n    var result = VmUtils.readMemberOrNull(object, propertyName, true, callNode);","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadPropertyNode.java#L76-L112","documentation":"This error is raised when an explicit-receiver property read (`obj.prop`) is evaluated against a `VmReference` (a deferred/reference value in the Pkl runtime) and the referenced object does not expose a property with that name. `evalReference` calls `receiver.withPropertyAccess(propertyName)`, which throws a `VmReferenceAccessError` on a failed member lookup; Pkl converts it into a 'cannot find property' error and attaches a hint describing why the lookup failed (member not found, external member, default member, or external class).","triggerScenarios":"Occurs when reading a property through an explicit receiver on a reference-typed value where the property does not exist on the referent's type: e.g. `someModuleRef.typoProp`, accessing a property declared in a sibling type, or referencing an external/default property that cannot be resolved through the reference.","commonSituations":"Typo'd property names on typed module or object references; a provider module renamed or removed a property so downstream `import` consumers break; accessing a property that exists on the concrete type but not on the declared reference type; reading properties of `external` or default-valued members that the reference cannot access.","solutions":["Read the error hint to see whether the property is missing, external, or default, then fix the property name on the reference read.","Verify the property exists on the referent's exported type (check the module/class definition you are referencing).","If the property is genuinely optional, guard with `'prop' in obj` or use `obj.getPropertyOrNull(\"prop\")` style access instead of direct dot access.","If a dependency module changed, update the consumer code or pin the dependency version."],"exampleFix":"// before\nimport \"myLib.pkl\"\noutput { text = myLib.connctionUrl } // error: no property `connctionUrl`\n\n// after\nimport \"myLib.pkl\"\noutput { text = myLib.connectionUrl }","handlingStrategy":"validation","validationCode":"// Pkl: verify a property exists on the referenced object before reading it\nfunction safeRead(obj: Object, key: String): any? =\n  if (key in obj) obj[key] else null","typeGuard":"// Pkl: narrow before direct dot access\nfunction hasProp(obj: Object, key: String): Boolean = key in obj\n// only use obj.myProp when hasProp(obj, \"myProp\") is true","tryCatchPattern":"// Pkl CLI/eval hosts: wrap module evaluation and inspect VmException for cannotFindProperty errors\ntry {\n  evaluate(module)\n} catch (e: PklException) {\n  if (e.message.contains(\"Cannot find property\")) {\n    // fall back to defaults or report the missing key\n  }\n}","preventionTips":["Rely on type-checked imports (`import \"...\"`) so unknown property names fail at type-check time.","Check the referent module's declared properties before dot-accessing through references.","Use `key in obj` or `obj[key]` for potentially absent properties."],"tags":["pkl","property-not-found","member-lookup","reference"],"backgroundTag":"resource-not-found","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"}