{"record":{"id":"e1845249092b2f41","repo":"apple/pkl","slug":"node-s-of-type-s-does-not-have-a-key-named","errorCode":null,"errorMessage":"Node `%s` of type `%s` does not have a key named `%s`. Available keys: %s","messagePattern":"Node `(.+?)` of type `(.+?)` does not have a key named `(.+?)`\\. Available keys: (.+?)","errorType":"exception","errorClass":"NoSuchChildException","httpStatus":null,"severity":"error","filePath":"pkl-config-java/src/main/java/org/pkl/config/java/MapConfig.java","lineNumber":40,"sourceCode":"class MapConfig extends AbstractConfig {\n  private final Map<?, ?> map;\n\n  MapConfig(String qualifiedName, ValueMapper mapper, Map<?, ?> map) {\n    super(qualifiedName, mapper);\n    this.map = map;\n  }\n\n  @Override\n  public Object getRawValue() {\n    return map;\n  }\n\n  @Override\n  protected Object getRawChildValue(String propertyName) {\n    var result = map.get(propertyName);\n    if (result != null) return result;\n\n    throw new NoSuchChildException(\n        String.format(\n            \"Node `%s` of type `%s` does not have a key named `%s`. Available keys: %s\",\n            getQualifiedName(), PClassInfo.Map.getQualifiedName(), propertyName, map.keySet()),\n        propertyName);\n  }\n}\n","sourceCodeStart":22,"sourceCodeEnd":47,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-config-java/src/main/java/org/pkl/config/java/MapConfig.java#L22-L47","documentation":"MapConfig wraps a Pkl Map. getRawChildValue looks up the requested key in the map and, when absent (null), throws NoSuchChildException listing the node name, the Pkl Map type, the requested key, and the keys that exist. Unlike a composite's properties, missing keys here are simply absent entries in the map.","triggerScenarios":"Accessing config children keyed by map keys (e.g. config.get(\"myMap\").get(\"missingKey\")) where the key string is not present in the Pkl map's keySet.","commonSituations":"Case or spelling mismatch between Java code and keys declared in the .pkl map; environment-specific entries (e.g. per-region keys) missing from a config file; keys computed dynamically (IDs, hostnames) that don't exist for the current environment.","solutions":["Correct the key using the 'Available keys' list printed in the exception.","Check the .pkl source to confirm the key exists and its exact spelling/casing.","Use a nullable/optional map lookup (map.get returns null check) when absence is expected.","Add the missing key to the Pkl map if the entry is genuinely required for this environment."],"exampleFix":"// before\nvar region = mapConfig.getChild(\"eu-west-3\"); // not in map\n// after\nif (mapConfig.getRawChildValue(\"eu-west-1\") == null) {\n  region = DEFAULT_REGION;\n} else {\n  region = mapConfig.getChild(\"eu-west-1\");\n}","handlingStrategy":"validation","validationCode":"// verify the key exists on the map config before access\nvar keys = mapConfig.getRawChildNames(); // or inspect the Pkl map's keySet\nif (!keys.contains(key)) {\n  throw new IllegalArgumentException(key + \" not in \" + keys);\n}","typeGuard":"static boolean hasKey(MapConfig map, String key) {\n  try { map.getRawChildValue(key); return true; }\n  catch (NoSuchChildException e) { return false; }\n}","tryCatchPattern":"try {\n  return mapConfig.getChild(key);\n} catch (NoSuchChildException e) {\n  log.warn(\"map config missing key {} (available: {})\", key, e.getAvailableKeys());\n  return Optional.empty();\n}","preventionTips":["Copy map keys exactly as declared in the .pkl source (watch case and dashes)","For optional entries, use nullable lookups instead of getChild","Add Pkl-level validation to require environment-critical keys","Treat 'Available keys' output as a diff against what your code expects"],"tags":["config","pkl","map","missing-key","lookup"],"backgroundTag":"missing-config-key","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"}