languagetool-org/languagetool · error · IllegalArgumentException

No IssueType found for name '" + name + "'. Valid values: "…

Error message

No IssueType found for name '" + name + "'. Valid values: " + Arrays.toString(values())

What it means

ITSIssueType.getIssueType(name) maps a string to one of the ITS issue type enum values; it iterates values() and throws IllegalArgumentException if no enum constant's toString() equals the input. The message lists all valid values.

Solutions

  1. Compare the input name against the list in the exception message and correct it to an exact, case-sensitive enum name (e.g. 'Uncategorized', 'Grammar', 'Typographical').
  2. Check the rule XML attribute that supplies the name and fix its value.
  3. If the input may be absent or free-form, wrap the call or pre-validate with a whitelist before calling getIssueType.

Example fix

// before
ITSIssueType type = ITSIssueType.getIssueType("grammar");
// after
ITSIssueType type = ITSIssueType.getIssueType("Grammatical");
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<String> VALID = Arrays.stream(ITSIssueType.values())
    .map(Enum::toString).collect(Collectors.toSet());
if (name != null && !VALID.contains(name)) {
  throw new IllegalArgumentException("Unknown ITS issue type: " + name);
}

Type guard

boolean isValidIssueType(String name) {
  return Arrays.stream(ITSIssueType.values()).anyMatch(t -> t.toString().equals(name));
}

Try / catch

try {
  type = ITSIssueType.getIssueType(name);
} catch (IllegalArgumentException e) {
  LOG.warn("Unknown ITS type '{}', defaulting to Uncategorized", name);
  type = ITSIssueType.Uncategorized;
}

Prevention

When it happens

Trigger: Calling ITSIssueType.getIssueType("...") with a name that is not exactly one of the enum constants (case-sensitive), typically a value read from an XML rule attribute (its:type).

Common situations: Typos or wrong casing in rule XML (e.g. 'grammar' vs 'Grammatical'), using free-form text instead of the ITS spec values, or mapping external categories to ITS types with values the library doesn't define.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at languagetool-core/src/main/java/org/languagetool/rules/ITSIssueType.java:46

 * 
 * @see <a href="http://www.w3.org/International/multilingualweb/lt/drafts/its20/its20.html#lqissue-typevalues">ITS 2.0</a>
 * @since 2.5
 */
public enum ITSIssueType {

  Terminology, Mistranslation, Omission, Untranslated, Addition, Duplication, Inconsistency, Grammar,
  Legal, Register, LocaleSpecificContent("locale-specific-content"), LocaleViolation("locale-violation"),
  Style, Characters, Misspelling, Typographical, Formatting, InconsistentEntities("inconsistent-entities"),
  Numbers, Markup, PatternProblem("pattern-problem"), Whitespace, Internationalization, Length, 
  NonConformance("non-conformance"), Uncategorized, Other;

  public static ITSIssueType getIssueType(String name) {
    for (ITSIssueType issueType : values()) {
      if (issueType.toString().equals(name)) {
        return issueType;
      }
    }
    throw new IllegalArgumentException("No IssueType found for name '" + name + "'. Valid values: " + Arrays.toString(values()));
  }

  private final String name;

  ITSIssueType() {
    this.name = name();
  }

  ITSIssueType(String name) {
    this.name = name;
  }

  /**
   * Use this to get the name as it is used in the ITS 2.0 standard
   * (namely lowercase and with hyphens, not camel case)
   */
  @Override
  public String toString() {

View on GitHub (pinned to 2e990059ce)