{"record":{"id":"ca6a3e64b7da1206","repo":"pentaho/pentaho-kettle","slug":"entry-not-found-key-key","errorCode":null,"errorMessage":"Entry not found [key={key}]","messagePattern":"Entry not found \\[key=(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/util/KeyValueSet.java","lineNumber":103,"sourceCode":"   * @return matching key values.\n   * @throws IllegalArgumentException\n   *           if filter is null.\n   */\n  public List<KeyValue<?>> get( final Predicate filter ) throws IllegalArgumentException {\n    final AddClosureArrayList<KeyValue<?>> result = new AddClosureArrayList<KeyValue<?>>();\n    this.walk( result, filter );\n    return result;\n  }\n\n  /**\n   * @param key\n   *          the key.\n   * @return key value, never null.\n   */\n  public KeyValue<?> getRequired( final String key ) {\n    final KeyValue<?> keyValue = this.get( key );\n    if ( keyValue == null ) {\n      throw new IllegalArgumentException( \"Entry not found [key=\" + key + \"]\" );\n    }\n    return keyValue;\n  }\n\n  /**\n   * @return keys.\n   */\n  public List<String> keys() {\n    return new ArrayList<String>( this.entries.keySet() );\n  }\n\n  /**\n   * @return key values/entries.\n   */\n  public List<KeyValue<?>> keyValues() {\n    return new ArrayList<KeyValue<?>>( this.entries.values() );\n  }\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/util/KeyValueSet.java#L85-L121","documentation":"KeyValueSet.getRequired throws IllegalArgumentException when the requested key has no entry in the set. It is the strict variant of get(): unlike get(), which returns null for missing keys, getRequired() guarantees a non-null KeyValue or throws. It exists so callers can safely dereference the result without a null check.","triggerScenarios":"Calling getRequired(key) with a key that was never added to the KeyValueSet, or after the entry was removed, or with a key whose spelling/case differs from the stored key.","commonSituations":"Typo in a property/parameter key name; reading a key that only exists in newer versions of a plugin or metadata file; case-sensitivity mismatches between where keys are written and where they are read.","solutions":["Verify the exact key string matches the key used when the entry was added (spelling and case).","Call set.get(key) and check for null first, or use contains(key), when absence is a legitimate state.","If the key should always exist, add it to the set at initialization before any getRequired() call.","Wrap in try-catch (IllegalArgumentException) when reading external/user-supplied key sets."],"exampleFix":"// before\nKeyValue<?> val = set.getRequired(\"porta\");\n// after\nKeyValue<?> val = set.get(\"port\") != null ? set.get(\"port\") : set.getRequired(\"port\");","handlingStrategy":"validation","validationCode":"if (set.get(\"myKey\") == null) {\n  throw new IllegalStateException(\"Key 'myKey' must be set before use\");\n}\nKeyValue<?> v = set.getRequired(\"myKey\");","typeGuard":"KeyValue<?> kv = set.get(key);\nif (kv == null) {\n  return null; // handle absence explicitly\n}","tryCatchPattern":"try {\n  KeyValue<?> kv = set.getRequired(key);\n  use(kv);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Missing entry: \" + e.getMessage());\n}","preventionTips":["Centralize key names in constants to avoid typos","Prefer get() with a null check when absence is legal","Populate all required keys at set initialization"],"tags":["illegal-argument","key-not-found","map-lookup"],"backgroundTag":"record-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}