{"record":{"id":"50139027c37492b8","repo":"languagetool-org/languagetool","slug":"json-output-format-makes-no-sense-for-profiling","errorCode":null,"errorMessage":"JSON output format makes no sense for profiling","messagePattern":"JSON output format makes no sense for profiling","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":161,"sourceCode":"        }\n        if (options.isBitext()) {\n          throw new IllegalArgumentException(\"JSON output format is not implemented for Bitext\");\n        }\n        if (options.isListUnknown()) {\n          throw new IllegalArgumentException(\"You cannot list unknown words in JSON output format\");\n        }\n      } else if (args[i].equals(\"-a\") || args[i].equals(\"--apply\")) {\n        options.setApplySuggestions(true);\n        if (options.isTaggerOnly()) {\n          throw new IllegalArgumentException(\"You cannot apply suggestions when tagging only\");\n        }\n        if (options.isJsonFormat()) {\n          throw new IllegalArgumentException(\"JSON output format makes no sense for automatic application of suggestions\");\n        }\n      } else if (args[i].equals(\"-p\") || args[i].equals(\"--profile\")) {\n        options.setProfile(true);\n        if (options.isJsonFormat()) {\n          throw new IllegalArgumentException(\"JSON output format makes no sense for profiling\");\n        }\n        if (options.isApplySuggestions()) {\n          throw new IllegalArgumentException(\"Applying suggestions makes no sense for profiling\");\n        }\n        if (options.isTaggerOnly()) {\n          throw new IllegalArgumentException(\"Tagging makes no sense for profiling\");\n        }\n      } else if (args[i].equals(\"--xmlfilter\")) {\n        options.setXmlFiltering(true);\n      } else if (i == args.length - 1) {\n        options.setFilename(args[i]);\n      } else {\n        throw new UnknownParameterException(\"Unknown parameter: \" + args[i]);\n      }\n    }\n    return options;\n  }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L143-L179","documentation":"parseOptions rejects -p/--profile together with -l/--json. Profiling mode prints a human-readable per-rule timing table, which cannot be represented in JSON, so the parser throws IllegalArgumentException for the combination.","triggerScenarios":"Command line includes both --profile (or -p) and --json (or -l), e.g. `languagetool -p --json file.txt`; checked inside the profile branch via options.isJsonFormat().","commonSituations":"Trying to capture rule-performance measurements as JSON for automated analysis; combining a benchmarking flag with an output-format flag in CI scripts.","solutions":["Remove --json when profiling; parse the tab-separated profiling table instead","Profile without --json and redirect stdout to a file for later processing","Do not attempt to combine the two modes; the parser will always reject it"],"exampleFix":"// before\nlanguagetool -l en -p --json file.txt\n// after\nlanguagetool -l en -p file.txt > profile.tsv","handlingStrategy":"validation","validationCode":"if (hasFlag(args, \"-p\", \"--profile\") && hasFlag(args, \"-l\", \"--json\")) {\n  throw new IllegalArgumentException(\"Profiling output is a text table, not JSON\");\n}","typeGuard":"static boolean hasFlag(String[] args, String... names) {\n  for (String a : args) for (String n : names) if (a.equals(n)) return true;\n  return false;\n}","tryCatchPattern":"try {\n  options = CommandLineParser.parseOptions(args);\n} catch (IllegalArgumentException e) {\n  System.err.println(e.getMessage());\n  System.exit(2);\n}","preventionTips":["Treat profiling output as tab-separated text, never JSON","Keep benchmark flags in dedicated scripts without output-format flags","Document in CI scripts that -p conflicts with -l"],"tags":["cli","commandline","profiling","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}