jenkinsci/jenkins · error · CmdLineException

'%s' is not a valid parameter. Did you mean %s?

Error message

'%s' is not a valid parameter. Did you mean %s?

What it means

Thrown as a CmdLineException when a parameter name passed via -p does not match any defined ParameterDefinition, but EditDistance.findNearest finds a close match. The message includes both the invalid name and the suggested correct name, helping the user fix typos.

Source

Thrown at core/src/main/java/hudson/cli/BuildCommand.java:118

    @Override
    protected int run() throws Exception {
        job.checkPermission(Item.BUILD);

        ParametersAction a = null;
        if (!parameters.isEmpty()) {
            ParametersDefinitionProperty pdp = job.getProperty(ParametersDefinitionProperty.class);
            if (pdp == null)
                throw new IllegalStateException(job.getFullDisplayName() + " is not parameterized but the -p option was specified.");

            //TODO: switch to type annotations after the migration to Java 1.8
            List<ParameterValue> values = new ArrayList<>();

            for (Map.Entry<String, String> e : parameters.entrySet()) {
                String name = e.getKey();
                ParameterDefinition pd = pdp.getParameterDefinition(name);
                if (pd == null) {
                    String nearest = EditDistance.findNearest(name, pdp.getParameterDefinitionNames());
                    throw new CmdLineException(null, nearest == null ?
                            String.format("'%s' is not a valid parameter.", name) :
                            String.format("'%s' is not a valid parameter. Did you mean %s?", name, nearest));
                }
                ParameterValue val = pd.createValue(this, Util.fixNull(e.getValue()));
                if (val == null) {
                    throw new CmdLineException(null, String.format("Cannot resolve the value for the parameter '%s'.", name));
                }
                values.add(val);
            }

            // handle missing parameters by adding as default values ISSUE JENKINS-7162
            for (ParameterDefinition pd : pdp.getParameterDefinitions()) {
                if (parameters.containsKey(pd.getName()))
                    continue;

                // not passed in use default
                ParameterValue defaultValue = pd.getDefaultParameterValue();
                if (defaultValue == null) {

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Use the suggested parameter name from the error message (the 'Did you mean X?' part).
  2. Copy the exact parameter name from the job's configuration to avoid typos.
  3. If multiple parameters have similar names, consider renaming them in the job config for clarity.
Defensive patterns

Strategy: validation

Validate before calling

// Validate and suggest corrections for parameter names
ParametersDefinitionProperty pdp = job.getProperty(ParametersDefinitionProperty.class);
for (String name : parameters.keySet()) {
    if (pdp.getParameterDefinition(name) == null) {
        String nearest = EditDistance.findNearest(name, pdp.getParameterDefinitionNames());
        String msg = nearest != null
            ? "Did you mean '" + nearest + "'?"
            : "No similar parameter found.";
        throw new AbortException("Invalid parameter '" + name + "'. " + msg);
    }
}

Try / catch

try {
    // build command run()
} catch (CmdLineException e) {
    // 'Did you mean' message is already user-friendly
    stderr.println(e.getMessage());
    return 1;
}

Prevention

When it happens

Trigger: pdp.getParameterDefinition(name) returns null, but EditDistance.findNearest(name, pdp.getParameterDefinitionNames()) returns a non-null string — a defined parameter name within edit-distance threshold.

Common situations: Minor typo in parameter name (e.g., 'BRNACH' instead of 'BRANCH'); case sensitivity issue; transposed characters; similar parameter names causing confusion.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/ae433b65c778a210. Report an issue: GitHub.