{"record":{"id":"8b16ff59ddd44eac","repo":"apache/maven","slug":"invalid-color-configuration-value-supported","errorCode":null,"errorMessage":"Invalid color configuration value '{}'. Supported are 'auto', 'always', 'never'.","messagePattern":"Invalid color configuration value '(.+?)'\\. Supported are 'auto', 'always', 'never'\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java","lineNumber":527,"sourceCode":"     * configure logging\n     */\n    void logging(CliRequest cliRequest) throws ExitException {\n        // LOG LEVEL\n        CommandLine commandLine = cliRequest.commandLine;\n        cliRequest.verbose = commandLine.hasOption(CLIManager.VERBOSE) || commandLine.hasOption(CLIManager.DEBUG);\n        cliRequest.quiet = !cliRequest.verbose && commandLine.hasOption(CLIManager.QUIET);\n        cliRequest.showErrors = cliRequest.verbose || commandLine.hasOption(CLIManager.ERRORS);\n\n        // LOG COLOR\n        String styleColor = cliRequest.getUserProperties().getProperty(\"style.color\", \"auto\");\n        styleColor = cliRequest.getUserProperties().getProperty(Constants.MAVEN_STYLE_COLOR_PROPERTY, styleColor);\n        styleColor = commandLine.getOptionValue(CLIManager.COLOR, styleColor);\n        if (\"always\".equals(styleColor) || \"yes\".equals(styleColor) || \"force\".equals(styleColor)) {\n            MessageUtils.setColorEnabled(true);\n        } else if (\"never\".equals(styleColor) || \"no\".equals(styleColor) || \"none\".equals(styleColor)) {\n            MessageUtils.setColorEnabled(false);\n        } else if (!\"auto\".equals(styleColor) && !\"tty\".equals(styleColor) && !\"if-tty\".equals(styleColor)) {\n            throw new IllegalArgumentException(\n                    \"Invalid color configuration value '\" + styleColor + \"'. Supported are 'auto', 'always', 'never'.\");\n        } else {\n            boolean isBatchMode = !commandLine.hasOption(CLIManager.FORCE_INTERACTIVE)\n                    && (commandLine.hasOption(CLIManager.BATCH_MODE)\n                            || commandLine.hasOption(CLIManager.NON_INTERACTIVE));\n            if (isBatchMode || commandLine.hasOption(CLIManager.LOG_FILE)) {\n                MessageUtils.setColorEnabled(false);\n            }\n        }\n\n        slf4jLoggerFactory = LoggerFactory.getILoggerFactory();\n        Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory);\n\n        if (cliRequest.verbose) {\n            cliRequest.request.setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_DEBUG);\n            slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.DEBUG);\n        } else if (cliRequest.quiet) {\n            cliRequest.request.setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_ERROR);","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L509-L545","documentation":"MavenCli resolves the log color setting from three places in order of precedence: the 'style.color' user property, the 'maven.style.color' user property, and the --color CLI option. The resolved string must be one of 'always', 'yes', 'force', 'never', 'no', 'none', 'auto', 'tty', or 'if-tty' (case-sensitive). Any other value throws IllegalArgumentException during CLI startup (MavenCli.logging()), before any project is read or built. Although the message names only three values, the aliases above are also accepted.","triggerScenarios":"Running mvn --color=true, --color=on, --color=1, or --color=Always (capitalized). Setting -Dstyle.color or -Dmaven.style.color (e.g. in MAVEN_OPTS, .mvn/maven.config, or CI environment) to a value outside the accepted set. A trailing space or quotes surviving into the property value also triggers it, because comparison is exact String.equals.","commonSituations":"Porting color settings from other tools (git color.ui=true, CLICOLOR_FORCE=1 style conventions) to Maven. CI pipelines exporting -Dstyle.color with a boolean value. Upgrading from setups where the property was ignored. Setting the property globally in MAVEN_OPTS and forgetting it is validated on every mvn invocation.","solutions":["Change the value to one of the accepted strings: 'auto' (default), 'always', or 'never' (aliases: yes/force, no/none, tty/if-tty).","Check MAVEN_OPTS, ~/.mavenrc, .mvn/maven.config and CI environment for a -Dstyle.color or -Dmaven.style.color property and fix or remove it.","Remove quotes/whitespace around the value, e.g. use --color=always not --color='always ' and verify the value is lowercase.","If you only wanted to force colors in CI, prefer the canonical form mvn -B --color=never or a TTY wrapper instead of boolean-style values."],"exampleFix":"# before\nmvn --color=true\nMAVEN_OPTS='-Dstyle.color=on'\n\n# after\nmvn --color=always\nMAVEN_OPTS='-Dstyle.color=always'","handlingStrategy":"validation","validationCode":"// Java, before invoking the CLI\nSet<String> ok = Set.of(\"auto\", \"tty\", \"if-tty\", \"always\", \"yes\", \"force\", \"never\", \"no\", \"none\");\nString color = firstNonNull(userProps.getProperty(\"maven.style.color\"),\n                            userProps.getProperty(\"style.color\"),\n                            cliArgValue(\"--color\")); // whatever your launcher passes\nif (color != null && !ok.contains(color)) {\n    throw new IllegalArgumentException(\"Rejecting invalid color value before mvn launch: \" + color);\n}","typeGuard":null,"tryCatchPattern":"// When embedding: catch around MavenCli.doMain\ntry {\n    cli.doMain(args, workingDir, ...);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid color configuration value\")) {\n        // surface a friendly message; fix config and retry once\n    }\n    throw e;\n}","preventionTips":["Keep a single source of truth for style.color (ideally .mvn/maven.config) instead of scattering -D flags through MAVEN_OPTS and CI variables.","Never use boolean-style color values (true/1/on) with Maven; the vocabulary is auto/always/never plus aliases.","Add a pipeline lint step that greps MAVEN_OPTS and maven.config for style.color values outside the accepted set."],"tags":["maven","cli","color","output-formatting","invalid-value","configuration"],"backgroundTag":"invalid-cli-option-value","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}