{"record":{"id":"4671c44116fa81d1","repo":"languagetool-org/languagetool","slug":"triggers-error-is-not-supported-for-bitext-xml","errorCode":null,"errorMessage":"'triggers_error' is not supported for bitext XML","messagePattern":"'triggers_error' is not supported for bitext XML","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/bitext/BitextPatternRuleHandler.java","lineNumber":158,"sourceCode":"\n  }\n\n  private IncorrectExample setExample() {\n    IncorrectExample example = null;\n    if (inCorrectExample) {\n      example = new IncorrectExample(correctExample.toString());\n    } else if (inIncorrectExample) {\n      if (exampleCorrection != null) {\n        List<String> corrections = new ArrayList<>(Arrays.asList(exampleCorrection.toString().split(\"\\\\|\")));\n        if (exampleCorrection.toString().endsWith(\"|\")) {  // suggestions plus an empty suggestion (split() will ignore trailing empty items)\n          corrections.add(\"\");\n        }\n        example = new IncorrectExample(incorrectExample.toString(), corrections);\n      } else {\n        example = new IncorrectExample(incorrectExample.toString());\n      }\n    } else if (inErrorTriggerExample) {\n      throw new RuntimeException(\"'triggers_error' is not supported for bitext XML\");\n    }\n    correctExample = new StringBuilder();\n    incorrectExample = new StringBuilder();\n    exampleCorrection = null;\n    return example;\n  }\n\n  private PatternRule finalizeRule() {\n    PatternRule rule = null;\n    if (phrasePatternTokens.isEmpty()) {\n      rule = new PatternRule(id, language, patternTokens,\n          name, \"\", shortMessage.toString());\n      prepareRule(rule);\n    } else {\n      if (!patternTokens.isEmpty()) {\n        for (List<PatternToken> ph : phrasePatternTokens) {\n          ph.addAll(new ArrayList<>(patternTokens));\n        }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/bitext/BitextPatternRuleHandler.java#L140-L176","documentation":"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.","triggerScenarios":"A bitext rules XML file includes <triggers_error>...</triggers_error> inside an <example> section; setExample hits inErrorTriggerExample while processing endElement and throws.","commonSituations":"Copying example blocks from monolingual rule XML into bitext rule files; automated rule conversion producing unsupported example types; template misuse.","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"],"exampleFix":"// before (bitext XML)\n<example>Incorrect sentence<triggers_error>word</triggers_error></example>\n// after\n<example>Incorrect sentence</example>","handlingStrategy":"validation","validationCode":"// Reject triggers_error in bitext rule files before loading\nif (isBitextRuleFile(file)) {\n  String xml = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);\n  if (xml.contains(\"triggers_error\")) {\n    throw new IllegalArgumentException(\"triggers_error is not allowed in bitext XML: \" + file);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  BitextPatternRuleLoader.getBitextRules(...);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"triggers_error\")) {\n    log.error(\"Remove triggers_error from bitext rule XML\", e);\n  } else throw e;\n}","preventionTips":["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"],"tags":["languagetool","bitext","xml-rules","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}