languagetool-org/languagetool · error · RuntimeException
'triggers_error' is not supported for bitext XML
Error message
'triggers_error' is not supported for bitext XML
What it means
BitextPatternRuleHandler.setExample throws this RuntimeException when a bitext (bilingual) rule XML contains a 'triggers_error' example element. The error-trigger example feature is only supported for monolingual pattern rules; the bitext loader cannot represent it, so parsing fails. Remove the element or move the rule to a monolingual grammar file.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/bitext/BitextPatternRuleHandler.java:158
}
private IncorrectExample setExample() {
IncorrectExample example = null;
if (inCorrectExample) {
example = new IncorrectExample(correctExample.toString());
} else if (inIncorrectExample) {
if (exampleCorrection != null) {
List<String> corrections = new ArrayList<>(Arrays.asList(exampleCorrection.toString().split("\\|")));
if (exampleCorrection.toString().endsWith("|")) { // suggestions plus an empty suggestion (split() will ignore trailing empty items)
corrections.add("");
}
example = new IncorrectExample(incorrectExample.toString(), corrections);
} else {
example = new IncorrectExample(incorrectExample.toString());
}
} else if (inErrorTriggerExample) {
throw new RuntimeException("'triggers_error' is not supported for bitext XML");
}
correctExample = new StringBuilder();
incorrectExample = new StringBuilder();
exampleCorrection = null;
return example;
}
private PatternRule finalizeRule() {
PatternRule rule = null;
if (phrasePatternTokens.isEmpty()) {
rule = new PatternRule(id, language, patternTokens,
name, "", shortMessage.toString());
prepareRule(rule);
} else {
if (!patternTokens.isEmpty()) {
for (List<PatternToken> ph : phrasePatternTokens) {
ph.addAll(new ArrayList<>(patternTokens));
}View on GitHub (pinned to 2e990059ce)
Solutions
- Remove the <triggers_error> element (and its content) from the bitext rule XML
- If the trigger test is needed, move that rule into a monolingual grammar XML where triggers_error is supported
- Update any rule-authoring templates/linters to reject triggers_error in bitext files
Example fix
// before (bitext XML) <example>Incorrect sentence<triggers_error>word</triggers_error></example> // after <example>Incorrect sentence</example>
Defensive patterns
Strategy: validation
Validate before calling
// Reject triggers_error in bitext rule files before loading
if (isBitextRuleFile(file)) {
String xml = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
if (xml.contains("triggers_error")) {
throw new IllegalArgumentException("triggers_error is not allowed in bitext XML: " + file);
}
} Try / catch
try {
BitextPatternRuleLoader.getBitextRules(...);
} catch (RuntimeException e) {
if (e.getMessage().contains("triggers_error")) {
log.error("Remove triggers_error from bitext rule XML", e);
} else throw e;
} Prevention
- Never copy <triggers_error> examples from monolingual rules into bitext files
- Keep bitext rule templates free of monolingual-only elements
- Grep bitext rule directories for 'triggers_error' in CI
When it happens
Trigger: A bitext rules XML file includes <triggers_error>...</triggers_error> inside an <example> section; setExample hits inErrorTriggerExample while processing endElement and throws.
Common situations: Copying example blocks from monolingual rule XML into bitext rule files; automated rule conversion producing unsupported example types; template misuse.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Your reference number ${refNumber} is bigger than number of
- Duplicate key '${key}'
- References cannot be empty: Line: ${pLocator.getLineNumber
- References must be larger than 0: ${attrs.getValue("no")} L
- Only backward references in match elements are possible, tri
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/4671c44116fa81d1.
Report an issue: GitHub.