{"record":{"id":"758c31d32692d9c5","repo":"karatelabs/karate","slug":"invalid-karate-options-ignored","errorCode":null,"errorMessage":"invalid karate.options ignored: {}","messagePattern":"invalid karate\\.options ignored: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateOptionsHandler.java","lineNumber":168,"sourceCode":"                logger.debug(\"karate.config.dir override: '{}' (Builder) -> '{}' ({})\",\n                        builder.getConfigDir(), value, source);\n            }\n            builder.setConfigDir(value);\n        }\n    }\n\n    /**\n     * Parse the options string using the v2 CLI grammar and apply it to the Builder.\n     * Package-private for direct testing.\n     */\n    static int parseAndApplyOptions(Runner.Builder builder, String raw, int threadCount) {\n        List<String> tokens = ProcessBuilder.tokenize(raw);\n        String[] argv = tokens.toArray(new String[0]);\n        RunCommand parsed = new RunCommand();\n        try {\n            new CommandLine(parsed).parseArgs(argv);\n        } catch (CommandLine.ParameterException e) {\n            logger.warn(\"invalid karate.options ignored: {}\", e.getMessage());\n            return threadCount;\n        }\n\n        // Collect applied summary for the INFO line\n        List<String> summary = new ArrayList<>();\n\n        // --- Paths (positional + -P) — REPLACE (v1 parity) ---\n        List<String> combinedPaths = new ArrayList<>();\n        if (parsed.getPaths() != null) combinedPaths.addAll(parsed.getPaths());\n        if (parsed.getPathOptions() != null) combinedPaths.addAll(parsed.getPathOptions());\n        if (!combinedPaths.isEmpty()) {\n            List<String> before = new ArrayList<>(builder.getPaths());\n            builder.clearPaths();\n            for (String p : combinedPaths) {\n                builder.path(p);\n            }\n            summary.add(\"paths=\" + combinedPaths);\n            if (logger.isDebugEnabled()) {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateOptionsHandler.java#L150-L186","documentation":"The `karate.options` system property string is tokenized into CLI arguments and parsed with the RunCommand CLI grammar. When picocli's CommandLine.parseArgs throws a ParameterException (unknown option, missing value, bad number, etc.), the whole options string is discarded with this warning and the run continues with the defaults (builder paths/tags and the given threadCount) — the invalid options are silently not applied.","triggerScenarios":"Setting the `karate.options` system property to a string that fails CLI parsing, e.g. `-Dkarate.options=\"-t@tag -t\"` (missing value), `--threads=abc` (non-numeric), or an unknown flag like `--out=x`, when Runner/apply() invokes parseAndApplyOptions.","commonSituations":"Typo in an option name; copying v1-only flags that the v2 RunCommand grammar no longer supports; shell quoting issues that split or merge tokens (quotes stripped/kept incorrectly); forgetting that a value-taking flag like `-t` or `--env` needs its argument.","solutions":["Run the same string through the CLI (or locally validate it) and fix the offending option/typo — the warning's `{}` payload is the picocli ParameterException message naming the exact bad argument.","Remove or correct the v1-only flags; check the v2 RunCommand supported options for equivalents.","Quote/escape the options string properly for the shell or Maven/Surefire argLine so tokens tokenize as intended.","If the warning is expected/acceptable, ignore it — the run proceeds with defaults; otherwise set options programmatically via Runner.Builder instead of the system property."],"exampleFix":"// before (bad: value missing for -t, flag unknown)\nSystem.setProperty(\"karate.options\", \"-t @smoke --out target\");\n// after\nSystem.setProperty(\"karate.options\", \"-t @smoke -o target\");","handlingStrategy":"validation","validationCode":"String raw = System.getProperty(\"karate.options\");\nif (raw != null) {\n    List<String> tokens = io.karatelabs.core.ProcessBuilder.tokenize(raw);\n    for (String t : tokens) {\n        if (t.startsWith(\"-\") && !t.matches(\"-t|-T|--tags|--env|--threads|-o|--output|--configdir|-f|--format|-n|--name|--dryrun|-P|--path\")) {\n            throw new IllegalArgumentException(\"unsupported karate.options token: \" + t);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate karate.options against the v2 RunCommand grammar before setting it in CI","Watch startup logs for 'karate.options applied: ...' — if absent, parsing failed and nothing was applied","Prefer Runner.Builder programmatic options over the system property when invoked from Java tests"],"tags":["cli-options","karate-options","argument-parsing","configuration"],"backgroundTag":"invalid-cli-argument","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}