{"record":{"id":"110ff67a1835385d","repo":"pentaho/pentaho-kettle","slug":"duplicate-parameter-key-detected","errorCode":null,"errorMessage":"Duplicate parameter '${key}' detected.","messagePattern":"Duplicate parameter '(.+?)' detected\\.","errorType":"exception","errorClass":"DuplicateParamException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/parameters/NamedParamsDefault.java","lineNumber":77,"sourceCode":"   * Default constructor.\n   */\n  public NamedParamsDefault() {\n  }\n\n  @Override\n  public void addParameterDefinition( String key, String defValue, String description ) throws DuplicateParamException {\n\n    if ( params.get( key ) == null ) {\n      OneNamedParam oneParam = new OneNamedParam();\n\n      oneParam.key = key;\n      oneParam.defaultValue = defValue;\n      oneParam.description = description;\n      oneParam.value = \"\";\n\n      params.put( key, oneParam );\n    } else {\n      throw new DuplicateParamException( \"Duplicate parameter '\" + key + \"' detected.\" );\n    }\n  }\n\n  @Override\n  public String getParameterDescription( String key ) throws UnknownParamException {\n    String description = null;\n\n    OneNamedParam theParam = params.get( key );\n    if ( theParam != null ) {\n      description = theParam.description;\n    }\n\n    return description;\n  }\n\n  @Override\n  public String getParameterValue( String key ) throws UnknownParamException {\n    String value = null;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/parameters/NamedParamsDefault.java#L59-L95","documentation":"NamedParamsDefault.addParameterDefinition registers a named parameter with a default value and description, storing it in an internal map. If a parameter with the same key already exists, it refuses to overwrite and throws DuplicateParamException. This protects existing parameter values from being silently reset by re-registration.","triggerScenarios":"Calling addParameterDefinition(key, defaultValue, description) twice with the same key, or via copyParametersFrom / mergeParametersWith when the source and target already share a parameter name.","commonSituations":"Merging two transformations/jobs that both define the same parameter; re-running setup code that adds parameters without first clearing them; copyParametersFrom into an object whose parameters were already populated.","solutions":["Check parameter existence first with existsParameter(key) (or listParameters()) and skip duplicates.","Call eraseParameters() before re-adding the full parameter set.","When copying, clear the destination first or filter out keys the target already defines.","If overwrite is intended, remove the old parameter then add the new definition."],"exampleFix":"// before\nparams.addParameterDefinition(\"MY_PARAM\", \"def\", \"desc\"); // throws if exists\n// after\nif (!params.existsParameter(\"MY_PARAM\")) {\n  params.addParameterDefinition(\"MY_PARAM\", \"def\", \"desc\");\n}","handlingStrategy":"validation","validationCode":"if (!namedParams.existsParameter(key)) {\n  namedParams.addParameterDefinition(key, defaultValue, description);\n}","typeGuard":"static boolean safeAddParameter(NamedParams params, String key, String def, String desc) {\n  try { params.addParameterDefinition(key, def, desc); return true; }\n  catch (DuplicateParamException e) { return false; }\n}","tryCatchPattern":"try {\n  params.addParameterDefinition(key, defaultValue, description);\n} catch (DuplicateParamException e) {\n  log.logBasic(\"Parameter already defined, keeping existing value: \" + key);\n}","preventionTips":["Guard every addParameterDefinition with existsParameter(key).","Call eraseParameters() before re-registering a full parameter set.","Deduplicate parameter names before copyParametersFrom/merge.","Keep a single source of truth for parameter definitions per transformation."],"tags":["kettle","parameters","duplicate-key"],"backgroundTag":"conflicting-config-options","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"}