{"record":{"id":"231fdfdd2abb9c59","repo":"languagetool-org/languagetool","slug":"suppressmisspelledsuggestions-must-be-a-valid-rege","errorCode":null,"errorMessage":"suppressMisspelledSuggestions must be a valid regex","messagePattern":"suppressMisspelledSuggestions 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":100,"sourceCode":"    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);\n  }\n\n  public FutureTask<RemoteRuleResult> run(List<AnalyzedSentence> sentences) {\n    return run(sentences, null);\n  }\n\n  protected static class RemoteRequest {}\n\n  /**","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/RemoteRule.java#L82-L118","documentation":"Same family as error 56 but for the optional RemoteRule option 'suppressMisspelledSuggestions': the constructor compiles its value into a Pattern, and an invalid regex is rethrown as IllegalArgumentException with this message.","triggerScenarios":"Setting RemoteRuleConfig option suppressMisspelledSuggestions to a string that Pattern.compile() rejects (syntax error such as unmatched '[', trailing '\\', or '+' with no operand).","commonSituations":"Copy-pasting grep-flavored regex into Java config, mis-escaping in properties/JSON layers, or generating the option value dynamically from user input without validation.","solutions":["Correct the suppressMisspelledSuggestions option value so it compiles as a Java regex.","Validate the pattern with Pattern.compile before loading config.","Drop the option if it's not needed — it's optional.","Double-check backslash escaping in the config file format."],"exampleFix":"// before\nsuppressMisspelledSuggestions=[misspelled\n// after\nsuppressMisspelledSuggestions=(misspelled|mistyped)","handlingStrategy":"try-catch","validationCode":"String opt = serviceConfig.getOptions().get(\"suppressMisspelledSuggestions\");\nif (opt != null) {\n  try { java.util.regex.Pattern.compile(opt); }\n  catch (java.util.regex.PatternSyntaxException e) {\n    throw new IllegalArgumentException(\"suppressMisspelledSuggestions 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(\"Bad suppressMisspelledSuggestions regex: {}\", e.getMessage());\n  throw e;\n}","preventionTips":["Keep both suppress* options in one validation helper","Use a Java-flavored regex validator, not PCRE/grep tools","Double-escape backslashes when the value passes through JSON"],"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"}