languagetool-org/languagetool · error · RuntimeException

Irish language expected, got " + language

Error message

Irish language expected, got " + language

What it means

Irish.getInstance() looks up the language registered for short code 'ga' and throws this RuntimeException if the registered Language is not an instance of Irish. This guards against the registry mapping 'ga' to a wrong or subclassed implementation.

Source

Thrown at languagetool-language-modules/ga/src/main/java/org/languagetool/language/Irish.java:176

  protected int getPriorityForId(String id) {
    switch (id) {
      case "TOO_LONG_PARAGRAPH": return -15;
    }
    return super.getPriorityForId(id);
  }

  @Nullable
  @Override
  protected SpellingCheckRule createDefaultSpellingRule(ResourceBundle messages) throws IOException {
    return new MorfologikIrishSpellerRule(messages, this, null, null);
  }

  public static @NotNull Irish getInstance() {
    Language language = Objects.requireNonNull(Languages.getLanguageForShortCode(LANGUAGE_SHORT_CODE));
    if (language instanceof Irish irish) {
      return irish;
    }
    throw new RuntimeException("Irish language expected, got " + language);
  }
}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Ensure no custom Language is registered under the 'ga' short code; remove or rename the conflicting registration.
  2. Check the classpath for duplicate languagetool-language-modules/ga jars of different versions.
  3. Call Irish.getInstance() before registering custom variants, or register the stock Irish language.
  4. Log the returned language's class name to identify which implementation is hijacking the code.

Example fix

// before (test stub registration)
Languages.addLanguage(new FakeIrishLanguage()); // registered under "ga"
// after
Languages.addLanguage(new FakeIrishLanguage("ga-FAKE")); // distinct short code
Defensive patterns

Strategy: type-guard

Validate before calling

Language l = Languages.getLanguageForShortCode("ga");
if (!(l instanceof Irish)) throw new IllegalStateException("'ga' bound to " + l.getClass());

Type guard

static boolean isIrish(Language l) { return l instanceof Irish; }

Try / catch

try { return Irish.getInstance(); } catch (RuntimeException e) { log.error("'ga' bound to wrong Language: " + e.getMessage()); throw e; }

Prevention

When it happens

Trigger: Languages.getLanguageForShortCode("ga") returns a non-Irish Language object — e.g. a custom/subclassed language registered under the 'ga' short code, or a modified Languages registry — and getInstance() then fails its instanceof check.

Common situations: Custom language variants overriding the 'ga' code; classpath conflicts with another jar registering 'ga'; test code registering a stub language under the same short code.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — 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/10774ea7a5c5c5d0. Report an issue: GitHub.