{"record":{"id":"47dd96acff5dafde","repo":"languagetool-org/languagetool","slug":"frompos-must-be-topos-frompos-frompos","errorCode":null,"errorMessage":"fromPos must be < toPos: fromPos: \" + fromPos + \", toPos: \" + toPos","messagePattern":"fromPos must be < toPos: fromPos: \" \\+ fromPos \\+ \", toPos: \" \\+ toPos","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/tagging/ner/NERService.java","lineNumber":150,"sourceCode":"    return res;\n  }\n\n  private int getLastSlashFrom(String s, int startPos) {\n    for (int i = startPos; i >= 0; i--) {\n      char ch = s.charAt(i);\n      if (ch == '/') {\n        return i;\n      }\n    }\n    return -1;\n  }\n\n  public static class Span {\n    private final int fromPos;\n    private final int toPos;\n    public Span(int fromPos, int toPos) {\n      if (fromPos >= toPos) {\n        throw new IllegalArgumentException(\"fromPos must be < toPos: fromPos: \" + fromPos + \", toPos: \" + toPos);\n      }\n      this.fromPos = fromPos;\n      this.toPos = toPos;\n    }\n    public int getStart() {\n      return fromPos;\n    }\n    public int getEnd() {\n      return toPos;\n    }\n    @Override\n    public String toString() {\n      return fromPos + \"-\" + toPos;\n    }\n  }\n}\n","sourceCodeStart":132,"sourceCodeEnd":167,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tagging/ner/NERService.java#L132-L167","documentation":"Constructor validation of the NERService.Span value class: a span with fromPos >= toPos is empty or reversed and cannot denote a text range. Generic argument guard — fires when callers pass swapped or bogus offsets, typically from misparsed NER output offsets.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tagging/ner/NERService.java:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure NER output offsets are parsed correctly and ordered start-before-end","Swap the arguments if they were passed in reverse","Handle zero-length spans separately instead of constructing an invalid Span"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}