languagetool-org/languagetool · error · RuntimeException
'triggers_error' is not supported for false friend XML
Error message
'triggers_error' is not supported for false friend XML
What it means
The false-friend XML schema only supports example types 'correct' and 'incorrect'. When the parser encounters an <example type="triggers_error"> element — a construct valid in grammar-rule XML but not in false-friend XML — it throws this RuntimeException.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/FalseFriendRuleHandler.java:120
if (Languages.isLanguageSupported(languageStr)) {
Language tmpLang = Languages.getLanguageForShortCode(languageStr);
currentTranslationLanguage = tmpLang;
if (inTestMode && currentTranslationLanguage == language) {
throw new RuntimeException("Translation language (" + currentTranslationLanguage + ") must not be the same as pattern language (" + language + ") for rule " + id);
}
if (tmpLang.equalsConsiderVariantsIfSpecified(motherTongue)) {
translationLanguage = tmpLang;
}
}
} else if (qName.equals(EXAMPLE)) {
correctExample = new StringBuilder();
incorrectExample = new StringBuilder();
if (attrs.getValue(TYPE).equals("incorrect")) {
inIncorrectExample = true;
} else if (attrs.getValue(TYPE).equals("correct")) {
inCorrectExample = true;
} else if (attrs.getValue(TYPE).equals("triggers_error")) {
throw new RuntimeException("'triggers_error' is not supported for false friend XML");
}
} else if (qName.equals(MESSAGE)) {
inMessage = true;
message = new StringBuilder();
} else if (qName.equals(RULEGROUP)) {
ruleGroupId = attrs.getValue("id");
inRuleGroup = true;
defaultOff = "off".equals(attrs.getValue(DEFAULT));
}
}
@Override
public void endElement(String namespaceURI, String sName,
String qName) throws SAXException {
switch (qName) {
case RULE:
if (language.equalsConsiderVariantsIfSpecified(textLanguage) && translationLanguage != null
&& translationLanguage.equalsConsiderVariantsIfSpecified(motherTongue) && language != motherTongueView on GitHub (pinned to 2e990059ce)
Solutions
- Remove the type="triggers_error" attribute from the example element in the false-friend XML
- Use only type="correct" or type="incorrect" in false-friend XML files
- Validate the file against the false-friend XML schema (false-friends rules use a different DTD/schema than pattern rules)
Example fix
// before <example type="triggers_error">He gave me a tip.</example> // after <example type="incorrect">He gave me a tip.</example>
Defensive patterns
Strategy: validation
Validate before calling
if (doc.getElementsByAttributeValue("type", "triggers_error").size() > 0) {
throw new IllegalArgumentException("triggers_error not allowed in false-friend XML");
} Try / catch
try {
rules = loader.getRules(file, language, motherTongue);
} catch (RuntimeException e) {
if (e.getMessage().contains("triggers_error")) {
log.error("Remove triggers_error examples from {}", file);
return Collections.emptyList();
}
throw e;
} Prevention
- Use the correct schema/DTD for false-friend XML, not grammar-rule XML
- Only use example types 'correct' and 'incorrect' in false-friend files
- Add a pre-commit XML validation step for rule resources
When it happens
Trigger: A <translation>/<example> element with type="triggers_error" inside a false-friend XML file processed by FalseFriendRuleHandler.startElement.
Common situations: Copy-pasting example markup from regular grammar rule XML into false-friends.xml, or writing false-friend rules using the wrong schema reference/autocomplete template.
Related errors
- Translation language (
- Could not load false friend rules from
- Set 'no', 'regexp' and 'postag_regexp' for filter PartialPos
- Wrong position in WhitespaceCheckFilter: " + pos + ", must b
- Missing key 'date'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/a8eef31f386eba7f.
Report an issue: GitHub.