{"record":{"id":"be8379de2267fd3f","repo":"apple/pkl","slug":"cannotfindmember-be8379","errorCode":null,"errorMessage":"cannotFindMember","messagePattern":"cannotFindMember","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java","lineNumber":310,"sourceCode":"      return Map.of();\n    }\n    var files = (VmMapping) filesOrNull;\n    var result = new LinkedHashMap<String, FileOutput>();\n    files.forceAndIterateMemberValues(\n        (key, member, value) -> {\n          assert member.isEntry();\n          result.put((String) key, fileOutputFactory.apply((VmTyped) value));\n          return true;\n        });\n    return result;\n  }\n\n  @TruffleBoundary\n  public static Object readMember(VmObjectLike receiver, Object memberKey) {\n    var result = readMemberOrNull(receiver, memberKey);\n    if (result != null) return result;\n\n    throw new VmExceptionBuilder().cannotFindMember(receiver, memberKey).build();\n  }\n\n  @TruffleBoundary\n  public static @Nullable Object readMemberOrNull(\n      VmObjectLike receiver, Object memberKey, boolean checkType) {\n    return readMemberOrNull(receiver, memberKey, checkType, IndirectCallNode.getUncached());\n  }\n\n  @TruffleBoundary\n  public static @Nullable Object readMemberOrNull(\n      VmObjectLike receiver, Object memberKey, IndirectCallNode callNode) {\n    return readMemberOrNull(receiver, memberKey, true, callNode);\n  }\n\n  @TruffleBoundary\n  public static @Nullable Object readMemberOrNull(VmObjectLike receiver, Object memberKey) {\n    return readMemberOrNull(receiver, memberKey, true, IndirectCallNode.getUncached());\n  }","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java#L292-L328","documentation":"Generic Pkl member lookup failure: `VmUtils.readMember` calls `readMemberOrNull` and, when the receiver has no member matching `memberKey`, throws a cannotFindMember error including the receiver and key. This is the standard 'undefined property' error for object access.","triggerScenarios":"Reading `obj.someKey` or `obj[\"someKey\"]` where `obj` (a VmObjectLike: object, module, or class instance) does not define that member and no catch-all/defaulting member exists.","commonSituations":"Typos in property names, config keys that differ in casing, accessing a property that exists in a newer Pkl stdlib/schema version but not the one in use, subscripting maps with keys that are absent.","solutions":["Fix the member name spelling/casing on the access site.","Verify the receiver actually defines the property (check the module/class schema).","Use a null-safe access (`obj[key] ?? default` or optional `?.` in host bindings) when the member is genuinely optional.","If reading a Map/List, check the key/index exists before access."],"exampleFix":"// before\nval port = server.porrt\n// after\nval port = server.port","handlingStrategy":"type-guard","validationCode":"// prefer null-safe access\nval v = obj?.key ?? defaultValue","typeGuard":"function hasMember(obj, key) { return obj != null && key in obj; }","tryCatchPattern":"try { return obj[key]; } catch (e) { return null; /* member missing */ }","preventionTips":["Verify property names against the module schema","Use typed bindings/generated code to catch typos at compile time","Prefer optional access with defaults for potentially absent members"],"tags":["pkl","member-access","undefined-property","runtime"],"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-14T16:17:12.679Z"}