{"record":{"id":"418761ce1f9e2f3e","repo":"languagetool-org/languagetool","slug":"no-end-error-marker-errormarker-getendmarker","errorCode":null,"errorMessage":"No end error marker ( + errorMarker.getEndMarker() + ) found in text with correction","messagePattern":"No end error marker \\( \\+ errorMarker\\.getEndMarker\\(\\) \\+ \\) found in text with correction","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/RuleMatchApplication.java","lineNumber":47,"sourceCode":"  private final String text;\n  private final String textWithCorrection;\n  private final ErrorMarker errorMarker;\n  private final boolean hasRealReplacement;\n\n  static RuleMatchApplication forMatchWithReplacement(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker) {\n    return new RuleMatchApplication(ruleMatch, text, textWithCorrection, errorMarker, true);\n  }\n\n  static RuleMatchApplication forMatchWithoutReplacement(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker) {\n    return new RuleMatchApplication(ruleMatch, text, textWithCorrection, errorMarker, false);\n  }\n\n  private RuleMatchApplication(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker, boolean hasRealReplacement) {\n    if (!textWithCorrection.contains(errorMarker.getStartMarker())) {\n      throw new IllegalArgumentException(\"No start error marker (\" + errorMarker.getStartMarker() + \") found in text with correction\");\n    }\n    if (!textWithCorrection.contains(errorMarker.getEndMarker())) {\n      throw new IllegalArgumentException(\"No end error marker (\" + errorMarker.getEndMarker() + \") found in text with correction\");\n    }\n    this.ruleMatch = ruleMatch;\n    this.text = text;\n    this.textWithCorrection = textWithCorrection;\n    this.errorMarker = errorMarker;\n    this.hasRealReplacement = hasRealReplacement;\n  }\n\n  public String getOriginalErrorContext(int contextSize) {\n    return getContext(text, contextSize);\n  }\n\n  public String getCorrectedErrorContext(int contextSize) {\n    return getContext(textWithCorrection, contextSize);\n  }\n\n  private String getContext(String text, int contextSize) {\n    int errorStart = textWithCorrection.indexOf(errorMarker.getStartMarker());","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/RuleMatchApplication.java#L29-L65","documentation":"Same validation as the start marker: the private RuleMatchApplication constructor requires the ErrorMarker's end marker to be present in textWithCorrection, otherwise an IllegalArgumentException is thrown. Without the end marker the corrected-region end offset cannot be computed.","triggerScenarios":"textWithCorrection contains the start marker but not the end marker — truncated text, an unbalanced marker (start inserted without closing), or markers removed between generation and this call.","commonSituations":"Regex/string replacement that consumed the closing marker; text truncated at a boundary cutting off the end tag; mismatched ErrorMarker constants.","solutions":["Ensure both start and end markers are preserved in textWithCorrection","Check the correction logic doesn't strip or consume the closing marker","Validate text completeness (no truncation) before constructing RuleMatchApplication","Use consistent ErrorMarker constants for generation and validation"],"exampleFix":"// before\ncorrected = text.replace(start, start); // loses end marker pairing\n// after\ncorrected = textWithMarkers; // contains \"<err>...</err>\" both markers intact","handlingStrategy":"validation","validationCode":"if (!textWithCorrection.contains(errorMarker.getEndMarker())) {\n  throw new IllegalStateException(\"correction text lost end marker\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  app = RuleMatchApplication.forMatchWithReplacement(match, text, corrected, marker, true);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"end marker missing in corrected text\", e);\n}","preventionTips":["Avoid replacements whose pattern spans the closing marker","Assert both markers present before constructing","Don't truncate marked-up text mid-marker"],"tags":["marker-validation","wikipedia","illegal-argument"],"backgroundTag":"invalid-argument-value","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"}