{"record":{"id":"3eec5920e16f1839","repo":"apache/maven","slug":"not-function-requires-exactly-one-argument","errorCode":null,"errorMessage":"not function requires exactly one argument","messagePattern":"not function requires exactly one argument","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java","lineNumber":170,"sourceCode":"    public Object matches(List<Object> args) {\n        if (args.size() != 2) {\n            throw new IllegalArgumentException(\"matches function requires exactly two arguments\");\n        }\n        String s = ConditionParser.toString(args.get(0));\n        String regex = ConditionParser.toString(args.get(1));\n        return s.matches(regex);\n    }\n\n    /**\n     * Negates a boolean value.\n     *\n     * @param args A list containing a single boolean argument\n     * @return The negation of the input boolean\n     * @throws IllegalArgumentException if the number of arguments is not exactly one\n     */\n    public Object not(List<Object> args) {\n        if (args.size() != 1) {\n            throw new IllegalArgumentException(\"not function requires exactly one argument\");\n        }\n        return !ConditionParser.toBoolean(args.get(0));\n    }\n\n    /**\n     * Implements an if-then-else operation.\n     *\n     * @param args A list containing three arguments: condition, value if true, value if false\n     * @return The second argument if the condition is true, the third argument otherwise\n     * @throws IllegalArgumentException if the number of arguments is not exactly three\n     */\n    @SuppressWarnings(\"checkstyle:MethodName\")\n    public Object if_(List<Object> args) {\n        if (args.size() != 3) {\n            throw new IllegalArgumentException(\"if function requires exactly three arguments\");\n        }\n        boolean condition = ConditionParser.toBoolean(args.get(0));\n        return condition ? args.get(1) : args.get(2);","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java#L152-L188","documentation":"not() is a built-in function of Maven 4.1 profile activation conditions (<activation><condition>). ConditionFunctions.not throws IllegalArgumentException unless exactly one boolean argument is supplied; the activator records 'Error parsing profile activation condition' and the profile remains inactive.","triggerScenarios":"A condition like not(exists('x'), exists('y')) with two arguments, or not() with none — the only valid form is not(<boolean expression>), e.g. not(exists('src/main/groovy')).","commonSituations":"Trying to negate two conditions in one call instead of using 'and'/'or' operators; an empty argument list left behind after deleting the inner expression.","solutions":["Wrap exactly one boolean expression: not(exists('src/main/groovy'))","For multiple conditions use operators, e.g. not(exists('a')) and not(exists('b'))","Verify with mvn help:active-profiles after the fix"],"exampleFix":"<!-- before -->\n<condition>not(exists('src/main/groovy'), exists('src/main/scala'))</condition>\n\n<!-- after -->\n<condition>not(exists('src/main/groovy')) and not(exists('src/main/scala'))</condition>","handlingStrategy":"validation","validationCode":"static boolean arityOk(String condition, String fn, int min, int max) {\n    int i = condition.indexOf(fn + \"(\");\n    if (i < 0) return true;\n    String args = condition.substring(i + fn.length() + 1, condition.indexOf(')', i));\n    int n = args.isBlank() ? 0 : args.split(\",\", -1).length;\n    return n >= min && n <= max;\n}\nboolean ok = arityOk(condition, \"not\", 1, 1);","typeGuard":null,"tryCatchPattern":"try {\n    Object r = new ConditionParser(functions, resolver).parse(condition);\n} catch (IllegalArgumentException e) {\n    // report and treat the profile as inactive\n}","preventionTips":["not wraps exactly one boolean expression; combine multiple negations with and/or","Prefer the De Morgan form (not(a or b) vs not(a) and not(b)) consistently across the team"],"tags":["maven","profile-activation","condition-functions","argument-mismatch","boolean"],"backgroundTag":"invalid-function-arguments","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}