languagetool-org/languagetool · error · IllegalArgumentException

Missing argument for '--logIpMatchingPattern' (e.g. any rand

Error message

Missing argument for '--logIpMatchingPattern' (e.g. any random String)

What it means

The --logIpMatchingPattern option requires a value (a regex-like string). If the next argument is missing (ArrayIndexOutOfBoundsException) the constructor throws this IllegalArgumentException. This throw site covers the case where the flag is the last argument on the command line.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:296

            }
          } catch (ArrayIndexOutOfBoundsException e) {
            allowOriginUrl = "*";
          }
          break;
        case LANGUAGE_MODEL_OPTION:
          setLanguageModelDirectory(args[++i]);
          break;
        case "--stoppable":  // internal only, doesn't need to be documented
          stoppable = true;
          break;
        case "--notLogIP":
          logIp = false;
          break;
        case "--logIpMatchingPattern":
          try {
            logIpMatchingPattern = args[++i];
            if (logIpMatchingPattern.startsWith("--")) {
              throw new IllegalArgumentException("Missing argument for '--logIpMatchingPattern' (e.g. any random String)");
            }
          } catch (ArrayIndexOutOfBoundsException e) {
            throw new IllegalArgumentException("Missing argument for '--logIpMatchingPattern' (e.g. any random String)");
          }
          break;
        default:
          if (args[i].contains("=")) {
            System.out.println("WARNING: unknown option: " + args[i] +
                    " - please note that parameters are given as '--arg param', i.e. without '=' between argument and parameter");
          } else {
            System.out.println("WARNING: unknown option: " + args[i]);
          }
      }
    }
  }

  private void parseConfigFile(File file, boolean loadLangModel) {
    try {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Append the pattern value after --logIpMatchingPattern on the command line
  2. Check the launch script/Docker CMD for truncation or line-continuation mistakes
  3. Pass a quoted string if the pattern contains special characters

Example fix

# before
java ... HTTPServer --port 8081 --logIpMatchingPattern
# after
java ... HTTPServer --port 8081 --logIpMatchingPattern "192\\.168\\..*"
Defensive patterns

Strategy: validation

Validate before calling

// verify every flag has its value before exec
for (int i = 0; i < args.length; i++) {
  if (args[i].equals("--logIpMatchingPattern") && (i + 1 >= args.length))
    throw new IllegalArgumentException("--logIpMatchingPattern needs a value");
}

Try / catch

try { cfg = new HTTPServerConfig(args); } catch (IllegalArgumentException e) {
  if (e.getMessage().contains("--logIpMatchingPattern")) { abortWithUsage(); } else throw e;
}

Prevention

When it happens

Trigger: Invoking the server with --logIpMatchingPattern as the final CLI argument so args[++i] throws ArrayIndexOutOfBoundsException.

Common situations: Truncated command lines in shell scripts or Dockerfiles; programmatically built arg arrays missing the trailing value; forgetting that parameters are separate space-delimited tokens.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/48d1112bca876b34. Report an issue: GitHub.