languagetool-org/languagetool · error · IllegalArgumentException
No start error marker ( + errorMarker.getStartMarker() + ) f
Error message
No start error marker ( + errorMarker.getStartMarker() + ) found in text with correction
What it means
RuleMatchApplication's private constructor validates that the corrected text still contains the ErrorMarker's start marker. If the marker string is not present, it throws IllegalArgumentException because the marker positions needed to compute offsets cannot be determined.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/wikipedia/RuleMatchApplication.java:44
public class RuleMatchApplication {
private final RuleMatch ruleMatch;
private final String text;
private final String textWithCorrection;
private final ErrorMarker errorMarker;
private final boolean hasRealReplacement;
static RuleMatchApplication forMatchWithReplacement(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker) {
return new RuleMatchApplication(ruleMatch, text, textWithCorrection, errorMarker, true);
}
static RuleMatchApplication forMatchWithoutReplacement(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker) {
return new RuleMatchApplication(ruleMatch, text, textWithCorrection, errorMarker, false);
}
private RuleMatchApplication(RuleMatch ruleMatch, String text, String textWithCorrection, ErrorMarker errorMarker, boolean hasRealReplacement) {
if (!textWithCorrection.contains(errorMarker.getStartMarker())) {
throw new IllegalArgumentException("No start error marker (" + errorMarker.getStartMarker() + ") found in text with correction");
}
if (!textWithCorrection.contains(errorMarker.getEndMarker())) {
throw new IllegalArgumentException("No end error marker (" + errorMarker.getEndMarker() + ") found in text with correction");
}
this.ruleMatch = ruleMatch;
this.text = text;
this.textWithCorrection = textWithCorrection;
this.errorMarker = errorMarker;
this.hasRealReplacement = hasRealReplacement;
}
public String getOriginalErrorContext(int contextSize) {
return getContext(text, contextSize);
}
public String getCorrectedErrorContext(int contextSize) {
return getContext(textWithCorrection, contextSize);
}View on GitHub (pinned to 2e990059ce)
Solutions
- Ensure the correction text retains the errorMarker start marker (e.g. <err> tags) until RuleMatchApplication is created
- Verify the same ErrorMarker instance/values used to produce textWithCorrection
- Check that prior processing did not strip markup before this call
- For tests, regenerate textWithCorrection with markers rather than editing it manually
Example fix
// before
String corrected = plainResult.replace("mistke", "mistake");
// after
String corrected = plainResult.replace("<err>mistke</err>", "<err>mistake</err>"); // keep markers
RuleMatchApplication.forMatchWithReplacement(match, text, corrected, errorMarker, true); Defensive patterns
Strategy: validation
Validate before calling
if (!textWithCorrection.contains(errorMarker.getStartMarker())) {
throw new IllegalStateException("correction text lost start marker");
} Try / catch
try {
app = RuleMatchApplication.forMatchWithoutReplacement(match, text, corrected, marker);
} catch (IllegalArgumentException e) {
LOG.error("markers missing in corrected text", e);
} Prevention
- Keep error markers intact through all text transformations
- Generate corrected text programmatically, never hand-edit
- Use one ErrorMarker constant set everywhere
When it happens
Trigger: Creating a RuleMatchApplication (via forMatchWithReplacement/forMatchWithoutReplacement) where textWithCorrection was built without embedding the errorMarker start marker — markers stripped too early or marker mismatch.
Common situations: Test fixtures where the correction text was hand-edited and markers removed; error marker constants changed between the producer and consumer; double application of a correction removing markers.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- No end error marker ( + errorMarker.getEndMarker() + ) found
- You have to set the source language (as mother tongue) in bi
- Unknown mode: <mode>
- '${langCode}' is not a language code known to LanguageTool.
- No IssueType found for name '" + name + "'. Valid values: "
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/1b36cedbfddb062a.
Report an issue: GitHub.