{"record":{"id":"fd10f03753a3bf74","repo":"jenkinsci/jenkins","slug":"s-is-not-a-valid-parameter","errorCode":null,"errorMessage":"'%s' is not a valid parameter.","messagePattern":"'(.+?)' is not a valid parameter\\.","errorType":"validation","errorClass":"CmdLineException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/BuildCommand.java","lineNumber":118,"sourceCode":"    @Override\n    protected int run() throws Exception {\n        job.checkPermission(Item.BUILD);\n\n        ParametersAction a = null;\n        if (!parameters.isEmpty()) {\n            ParametersDefinitionProperty pdp = job.getProperty(ParametersDefinitionProperty.class);\n            if (pdp == null)\n                throw new IllegalStateException(job.getFullDisplayName() + \" is not parameterized but the -p option was specified.\");\n\n            //TODO: switch to type annotations after the migration to Java 1.8\n            List<ParameterValue> values = new ArrayList<>();\n\n            for (Map.Entry<String, String> e : parameters.entrySet()) {\n                String name = e.getKey();\n                ParameterDefinition pd = pdp.getParameterDefinition(name);\n                if (pd == null) {\n                    String nearest = EditDistance.findNearest(name, pdp.getParameterDefinitionNames());\n                    throw new CmdLineException(null, nearest == null ?\n                            String.format(\"'%s' is not a valid parameter.\", name) :\n                            String.format(\"'%s' is not a valid parameter. Did you mean %s?\", name, nearest));\n                }\n                ParameterValue val = pd.createValue(this, Util.fixNull(e.getValue()));\n                if (val == null) {\n                    throw new CmdLineException(null, String.format(\"Cannot resolve the value for the parameter '%s'.\", name));\n                }\n                values.add(val);\n            }\n\n            // handle missing parameters by adding as default values ISSUE JENKINS-7162\n            for (ParameterDefinition pd : pdp.getParameterDefinitions()) {\n                if (parameters.containsKey(pd.getName()))\n                    continue;\n\n                // not passed in use default\n                ParameterValue defaultValue = pd.getDefaultParameterValue();\n                if (defaultValue == null) {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/BuildCommand.java#L100-L136","documentation":"Thrown as a CmdLineException when a parameter name passed via -p does not match any defined ParameterDefinition, and EditDistance.findNearest returns null (no close match exists among the defined parameter names). The message includes only the invalid parameter name.","triggerScenarios":"pdp.getParameterDefinition(name) returns null for the given -p key, and EditDistance.findNearest(name, pdp.getParameterDefinitionNames()) returns null — meaning no defined parameter name is within edit-distance threshold of the provided name.","commonSituations":"Significant typo in parameter name; parameter was renamed or removed from the job; copy-paste error from documentation or another job's parameters; wrong job targeted.","solutions":["List the job's defined parameters: 'jenkins-cli build <job>' without -p, or check the job's parameter definitions in the UI.","Correct the parameter name in the -p argument to match a defined parameter exactly.","If the parameter was renamed, update the calling script to use the new name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate parameter names against defined parameters\nParametersDefinitionProperty pdp = job.getProperty(ParametersDefinitionProperty.class);\nif (pdp != null) {\n    for (String name : parameters.keySet()) {\n        if (pdp.getParameterDefinition(name) == null) {\n            throw new AbortException(\"Parameter '\" + name + \"' is not defined on job. Defined: \" + pdp.getParameterDefinitionNames());\n        }\n    }\n}","typeGuard":"public static boolean isValidParameterName(ParametersDefinitionProperty pdp, String name) {\n    return pdp.getParameterDefinition(name) != null;\n}","tryCatchPattern":"try {\n    // build command run()\n} catch (CmdLineException e) {\n    if (e.getMessage().contains(\"is not a valid parameter\")) {\n        stderr.println(e.getMessage());\n        stderr.println(\"Run with --help or check the job's parameter definitions.\");\n        return 1;\n    }\n    throw e;\n}","preventionTips":["Fetch the job's parameter list from the API before constructing the CLI command.","Use exact parameter names from the job configuration.","Validate parameter names in automation scripts against the API response."],"tags":["cli","build","parameters","validation"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}