{"record":{"id":"25ec324082a90d0a","repo":"languagetool-org/languagetool","slug":"check-failed-on-sentence-stringutils-abbreviate","errorCode":null,"errorMessage":"Check failed on sentence: ${StringUtils.abbreviate(sentence.getText(), 250)}","messagePattern":"Check failed on sentence: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/SentenceSourceChecker.java","lineNumber":278,"sourceCode":"          if (options.hasOption(\"print-correct\")) {\n            if (matches.getRuleMatches().size() == 0) {\n              System.out.println(sentence.getText());\n            }\n          } else {\n            resultHandler.handleResult(sentence, matches.getRuleMatches(), lang);\n          }\n          sentenceCount++;\n          if (sentenceCount % 5000 == 0) {\n            System.err.printf(\"%s sentences checked...\\n\", NumberFormat.getNumberInstance(Locale.US).format(sentenceCount));\n          }\n          ruleMatchCount += matches.getRuleMatches().size();\n        } catch (DocumentLimitReachedException | ErrorLimitReachedException e) {\n          throw e;\n        } catch (Exception e) {\n          if (options.hasOption(\"skip-exceptions\")) {\n            e.printStackTrace();\n          } else {\n            throw new RuntimeException(\"Check failed on sentence: \" + StringUtils.abbreviate(sentence.getText(), 250), e);\n          }\n        }\n      }\n      ignoredCount = mixingSource.getIgnoredCount();\n    } catch (DocumentLimitReachedException | ErrorLimitReachedException e) {\n      System.out.println(getClass().getSimpleName() + \": \" + e);\n    } finally {\n      lt.shutdown();\n      if (resultHandler != null) {\n        System.out.printf(lang + \": %d total matches\\n\", ruleMatchCount);\n        System.out.printf(lang + \": %d total sentences considered\\n\", sentenceCount);\n        float matchesPerSentence = (float)ruleMatchCount / sentenceCount;\n        System.out.printf(Locale.ENGLISH, lang + \": ø%.2f rule matches per sentence\\n\", matchesPerSentence);\n        System.out.printf(Locale.ENGLISH, lang + \": %d input lines ignored (e.g. not between %d and %d chars or at least %d tokens)\\n\", ignoredCount, \n          SentenceSource.MIN_SENTENCE_LENGTH, SentenceSource.MAX_SENTENCE_LENGTH, SentenceSource.MIN_SENTENCE_TOKEN_COUNT);\n        if (options.hasOption(\"print-duration\")) {\n          System.out.println(\"The analysis took \" + (System.currentTimeMillis() - startTime) + \"ms\");\n        }","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/SentenceSourceChecker.java#L260-L296","documentation":"During SentenceSourceChecker.run, if checking an individual sentence throws any exception other than the control-flow DocumentLimitReachedException/ErrorLimitReachedException, it is wrapped in a RuntimeException quoting the first 250 characters of the sentence. Unless --skip-exceptions is set, one bad sentence aborts the whole run. The wrap exists to pinpoint which sentence broke the check.","triggerScenarios":"LanguageTool rule code throws on pathological sentence text (regex stack overflow, null handling); the sentence source yields corrupt text; a plugin/rule bug triggered by specific content.","commonSituations":"StackOverflowError in regex-based rules on very long sentences; NPEs in custom rules; unusual Unicode in Wikipedia articles.","solutions":["Read the truncated sentence text in the message to find the offending content","Re-run with --skip-exceptions to print stack traces and continue past bad sentences","Fix or disable the specific rule that fails on that sentence","Catch and skip in a wrapper around your own check pipeline"],"exampleFix":"// before\njava ... -l en dump.xml\n// after\njava ... -l en --skip-exceptions dump.xml","handlingStrategy":"try-catch","validationCode":"// pre-screen sentences before the checker\nif (sentence.getText() == null || sentence.getText().length() > 5000) {\n  return; // skip pathological sentences\n}","typeGuard":null,"tryCatchPattern":"try {\n  checker.run(dumpFiles);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Check failed on sentence\")) {\n    log.warn(\"Skipping run at sentence: \" + e.getMessage(), e);\n  } else throw e;\n}","preventionTips":["Run with --skip-exceptions for bulk unattended jobs","Disable rules known to choke on long/pathological text","Keep sentences bounded in your own source filters","Capture the offending sentence text from the message to build a regression corpus"],"tags":["processing","sentence-check","robustness"],"backgroundTag":"sentence-processing-failed","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"}