{"record":{"id":"6e13ae3dff649bd3","repo":"apache/maven","slug":"inrange-function-requires-exactly-two-arguments","errorCode":null,"errorMessage":"inrange function requires exactly two arguments","messagePattern":"inrange function requires exactly two arguments","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java","lineNumber":234,"sourceCode":"     */\n    public Object missing(List<Object> args) {\n        if (args.size() != 1) {\n            throw new IllegalArgumentException(\"missing function requires exactly one argument\");\n        }\n        String path = ConditionParser.toString(args.get(0));\n        return !context.exists(path, true);\n    }\n\n    /**\n     * Checks if a version is within a specified version range.\n     *\n     * @param args A list containing two strings: the version to check and the version range\n     * @return true if the version is within the range, false otherwise\n     * @throws IllegalArgumentException if the number of arguments is not exactly two\n     */\n    public Object inrange(List<Object> args) {\n        if (args.size() != 2) {\n            throw new IllegalArgumentException(\"inrange function requires exactly two arguments\");\n        }\n        String version = ConditionParser.toString(args.get(0));\n        String range = ConditionParser.toString(args.get(1));\n        return versionParser.parseVersionRange(range).contains(versionParser.parseVersion(version));\n    }\n\n    /**\n     * Checks whether a given executable can be found in the system PATH, or – if an\n     * absolute / relative path is supplied – whether that path itself is an executable file.\n     *\n     * <p><strong>Warning:</strong> relying on local system environment variables like PATH makes\n     * profile activation non-reproducible. This function should typically be used only in local\n     * build profiles and not in consumer POMs that are published to a remote repository.</p>\n     *\n     * <p>Usage examples in a profile {@code <condition>}:\n     * <pre>\n     *   executable('musl-gcc')\n     *   executable('x86_64-linux-musl-gcc')","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionFunctions.java#L216-L252","documentation":"inrange() is a built-in function of Maven 4.1 profile activation conditions (<activation><condition>). ConditionFunctions.inrange throws IllegalArgumentException unless exactly two string arguments are given in the order (version, range); the range is parsed with the Maven VersionParser, e.g. inrange(${maven.version}, '[4.0,)'). The activator converts the failure into 'Error parsing profile activation condition'.","triggerScenarios":"A condition like inrange(${maven.version}) missing the range, or a third argument — only the two-argument form (version, range) is accepted.","commonSituations":"Migrating from the old jdk-activation style checks to the new condition syntax; forgetting which argument comes first (order matters: version first, range second); typos in the range syntax, which instead surface as a VersionParser error.","solutions":["Always pass (version, range) as two arguments: inrange(${maven.version}, '[4.0,)')","Use ${maven.version} (not java.version) when you mean the Maven runtime version; use jdk-related properties for JDK checks","Verify with mvn help:active-profiles after the fix"],"exampleFix":"<!-- before -->\n<condition>inrange(${maven.version})</condition>\n\n<!-- after -->\n<condition>inrange(${maven.version}, '[4.0,)')</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, \"inrange\", 2, 2);","typeGuard":null,"tryCatchPattern":"try {\n    Object r = new ConditionParser(functions, resolver).parse(condition);\n} catch (IllegalArgumentException e) {\n    // arity error; malformed ranges throw from VersionParser instead\n}","preventionTips":["inrange argument order is (version, range), e.g. inrange(${maven.version}, '[4.0,)')","Use ${maven.version} for Maven checks and JDK properties for Java checks; they are not interchangeable"],"tags":["maven","profile-activation","condition-functions","argument-mismatch","version-range"],"backgroundTag":"invalid-function-arguments","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}