apache/maven · error · IllegalArgumentException

upper function requires exactly one argument

Error message

upper function requires exactly one argument

What it means

upper() is a built-in function of Maven 4.1 profile activation conditions (<activation><condition>). ConditionFunctions.upper throws IllegalArgumentException unless exactly one argument is supplied; the activator converts it into an 'Error parsing profile activation condition' problem and the profile stays inactive.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java:75

     */
    public Object length(List<Object> args) {
        if (args.size() != 1) {
            throw new IllegalArgumentException("length function requires exactly one argument");
        }
        String s = ConditionParser.toString(args.get(0));
        return s.length();
    }

    /**
     * Converts the given string to uppercase.
     *
     * @param args A list containing a single string argument
     * @return The uppercase version of the input string
     * @throws IllegalArgumentException if the number of arguments is not exactly one
     */
    public Object upper(List<Object> args) {
        if (args.size() != 1) {
            throw new IllegalArgumentException("upper function requires exactly one argument");
        }
        String s = ConditionParser.toString(args.get(0));
        return s.toUpperCase();
    }

    /**
     * Converts the given string to lowercase.
     *
     * @param args A list containing a single string argument
     * @return The lowercase version of the input string
     * @throws IllegalArgumentException if the number of arguments is not exactly one
     */
    public Object lower(List<Object> args) {
        if (args.size() != 1) {
            throw new IllegalArgumentException("lower function requires exactly one argument");
        }
        String s = ConditionParser.toString(args.get(0));
        return s.toLowerCase();

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Rewrite the call as upper(x) with exactly one argument, e.g. upper(${os.name}) == 'LINUX'
  2. Verify with mvn help:active-profiles that the profile activates
  3. Compare against the function reference for supported signatures (no locale variant exists)

Example fix

<!-- before -->
<condition>upper(${os.name}, 'en') == 'LINUX'</condition>

<!-- after -->
<condition>upper(${os.name}) == 'LINUX'</condition>
Defensive patterns

Strategy: validation

Validate before calling

static boolean arityOk(String condition, String fn, int min, int max) {
    int i = condition.indexOf(fn + "(");
    if (i < 0) return true;
    String args = condition.substring(i + fn.length() + 1, condition.indexOf(')', i));
    int n = args.isBlank() ? 0 : args.split(",", -1).length;
    return n >= min && n <= max;
}
boolean ok = arityOk(condition, "upper", 1, 1);

Try / catch

try {
    Object r = new ConditionParser(functions, resolver).parse(condition);
} catch (IllegalArgumentException e) {
    // report and treat the profile as inactive
}

Prevention

When it happens

Trigger: A condition like upper(${os.name}, true) or upper() — the function takes exactly one string, e.g. upper(${os.name}) == 'LINUX'.

Common situations: Adding a locale or flag argument by analogy with other languages' toUpperCase(value, locale); a stray comma while editing the condition; templates that inject empty values leaving upper().

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/5faef441e794ec43. Report an issue: GitHub.