{"record":{"id":"10774ea7a5c5c5d0","repo":"languagetool-org/languagetool","slug":"irish-language-expected-got-language","errorCode":null,"errorMessage":"Irish language expected, got \" + language","messagePattern":"Irish language expected, got \" \\+ language","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/ga/src/main/java/org/languagetool/language/Irish.java","lineNumber":176,"sourceCode":"  protected int getPriorityForId(String id) {\n    switch (id) {\n      case \"TOO_LONG_PARAGRAPH\": return -15;\n    }\n    return super.getPriorityForId(id);\n  }\n\n  @Nullable\n  @Override\n  protected SpellingCheckRule createDefaultSpellingRule(ResourceBundle messages) throws IOException {\n    return new MorfologikIrishSpellerRule(messages, this, null, null);\n  }\n\n  public static @NotNull Irish getInstance() {\n    Language language = Objects.requireNonNull(Languages.getLanguageForShortCode(LANGUAGE_SHORT_CODE));\n    if (language instanceof Irish irish) {\n      return irish;\n    }\n    throw new RuntimeException(\"Irish language expected, got \" + language);\n  }\n}\n","sourceCodeStart":158,"sourceCodeEnd":179,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/ga/src/main/java/org/languagetool/language/Irish.java#L158-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure no custom Language is registered under the 'ga' short code; remove or rename the conflicting registration.","Check the classpath for duplicate languagetool-language-modules/ga jars of different versions.","Call Irish.getInstance() before registering custom variants, or register the stock Irish language.","Log the returned language's class name to identify which implementation is hijacking the code."],"exampleFix":"// before (test stub registration)\nLanguages.addLanguage(new FakeIrishLanguage()); // registered under \"ga\"\n// after\nLanguages.addLanguage(new FakeIrishLanguage(\"ga-FAKE\")); // distinct short code","handlingStrategy":"type-guard","validationCode":"Language l = Languages.getLanguageForShortCode(\"ga\");\nif (!(l instanceof Irish)) throw new IllegalStateException(\"'ga' bound to \" + l.getClass());","typeGuard":"static boolean isIrish(Language l) { return l instanceof Irish; }","tryCatchPattern":"try { return Irish.getInstance(); } catch (RuntimeException e) { log.error(\"'ga' bound to wrong Language: \" + e.getMessage()); throw e; }","preventionTips":["Don't register custom languages under built-in short codes","Check for duplicate language-module jars on the classpath","Register custom variants with unique short codes"],"tags":["java","languagetool","registry","irish"],"backgroundTag":"unexpected-api-response-shape","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"}