{"record":{"id":"cdff8c4c856ac6da","repo":"languagetool-org/languagetool","slug":"suppressmisspelledmatch-must-be-a-valid-regex","errorCode":null,"errorMessage":"suppressMisspelledMatch must be a valid regex","messagePattern":"suppressMisspelledMatch must be a valid regex","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/RemoteRule.java","lineNumber":91,"sourceCode":"    this.lt = this.ruleLanguage.createDefaultJLanguageTool();\n    this.inputLogging = inputLogging;\n    if (ruleId == null) { // allow both providing rule ID in constructor or overriding getId\n      ruleId = getId();\n    }\n    filterMatches = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault(\"filterMatches\", \"false\"));\n    whitespaceNormalisation = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault(\"whitespaceNormalisation\", \"true\"));\n    fixOffsets = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault(\"fixOffsets\", \"true\"));\n    premium = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault(\"premium\", \"false\"));\n    boolean includedInHiddenMatches = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault(\"includedInHiddenMatches\", \"true\"));\n    setIncludedInHiddenMatches(includedInHiddenMatches);\n    try {\n      if (serviceConfiguration.getOptions().containsKey(\"suppressMisspelledMatch\")) {\n        suppressMisspelledMatch = Pattern.compile(serviceConfiguration.getOptions().get(\"suppressMisspelledMatch\"));\n      } else {\n        suppressMisspelledMatch = null;\n      }\n    } catch(PatternSyntaxException e) {\n      throw new IllegalArgumentException(\"suppressMisspelledMatch must be a valid regex\", e);\n    }\n    try {\n      if (serviceConfiguration.getOptions().containsKey(\"suppressMisspelledSuggestions\")) {\n        suppressMisspelledSuggestions = Pattern.compile(serviceConfiguration.getOptions().get(\"suppressMisspelledSuggestions\"));\n      } else {\n        suppressMisspelledSuggestions = null;\n      }\n    } catch(PatternSyntaxException e) {\n      throw new IllegalArgumentException(\"suppressMisspelledSuggestions must be a valid regex\", e);\n    }\n  }\n\n  public RemoteRule(Language language, ResourceBundle messages, RemoteRuleConfig config, boolean inputLogging) {\n    this(language, messages, config, inputLogging, null);\n  }\n\n  public static void shutdown() {\n    shutdownRoutines.forEach(Runnable::run);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/RemoteRule.java#L73-L109","documentation":"RemoteRule's constructor compiles the optional service option 'suppressMisspelledMatch' as a java.util.regex.Pattern. If the option value is present but not syntactically valid regex, PatternSyntaxException is rethrown as IllegalArgumentException with this message.","triggerScenarios":"Configuring a remote rule's RemoteRuleConfig options with suppressMisspelledMatch set to an invalid regex string (unbalanced parens, dangling quantifier, bad escape).","commonSituations":"Typing a glob-style pattern ('*.ogg') where a regex is required, escaping confusion in config/JSON files (e.g. '\\\\b' vs '\\b'), or copy-pasting patterns with shell-mangled backslashes.","solutions":["Fix the suppressMisspelledMatch option value to be valid Java regex syntax (e.g. '\\\\bmisspelled\\\\b').","Test the pattern with Pattern.compile() in a snippet or a regex validator set to Java flavor.","Remove the option entirely if suppression is not needed (it is optional).","Check escaping in the config file format (properties/JSON may require doubling backslashes)."],"exampleFix":"// before (config)\nsuppressMisspelledMatch=*.ogg\n// after\nsuppressMisspelledMatch=.*\\\\.ogg","handlingStrategy":"try-catch","validationCode":"String opt = serviceConfig.getOptions().get(\"suppressMisspelledMatch\");\nif (opt != null) {\n  try { java.util.regex.Pattern.compile(opt); }\n  catch (java.util.regex.PatternSyntaxException e) {\n    throw new IllegalArgumentException(\"suppressMisspelledMatch is not valid regex: \" + e.getMessage());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  rule = new RemoteRule(language, messages, config, inputLogging);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"RemoteRule config rejected: {}\", e.getMessage());\n  throw e; // config must be fixed before retry\n}","preventionTips":["Validate regex options at config-load time, not rule-construction time","Remember Java regex escaping in properties/JSON files","Test remote-rule configs with Pattern.compile in a smoke test"],"tags":["java","languagetool","regex","configuration"],"backgroundTag":"invalid-regex-pattern","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"}