{"record":{"id":"82e8c692e5ddff3c","repo":"languagetool-org/languagetool","slug":"your-text-s-length-exceeds-this-server-s-hard-limi","errorCode":null,"errorMessage":"Your text's length exceeds this server's hard limit of  characters.","messagePattern":"Your text's length exceeds this server's hard limit of  characters\\.","errorType":"http","errorClass":"TextTooLongException","httpStatus":413,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java","lineNumber":468,"sourceCode":"    }\n  }\n\n  private String readerToString(Reader reader, int maxTextLength) throws IOException {\n    StringBuilder sb = new StringBuilder();\n    char[] chars = new char[4000];\n    while (true) {\n      int readBytes = reader.read(chars, 0, 4000);\n      if (readBytes <= 0) {\n        break;\n      }\n      int generousMaxLength = maxTextLength * 10;  // one character can be encoded as e.g. \"%D8\", plus estimated space for sending data (JSON)\n      if (generousMaxLength < 0) {  // might happen as it can overflow\n        generousMaxLength = Integer.MAX_VALUE;\n      }\n      if (sb.length() > 0 && sb.length() > generousMaxLength) {\n        // don't stop at maxTextLength as that's the text length, but here also other parameters\n        // are included (still we need this check here so we don't OOM if someone posts a few hundred MB)...\n        throw new TextTooLongException(\"Your text's length exceeds this server's hard limit of \" + generousMaxLength + \" characters.\");\n      }\n      sb.append(new String(chars, 0, readBytes));\n    }\n    return sb.toString();\n  }\n\n\n  private Map<String, String> parseQuery(String query, HttpExchange httpExchange) throws UnsupportedEncodingException {\n    Map<String, String> parameters = new HashMap<>();\n    if (query != null) {\n      parameters.putAll(getParameterMap(query, httpExchange));\n    }\n    return parameters;\n  }\n\n  private Map<String, String> getParameterMap(String query, HttpExchange httpExchange) throws UnsupportedEncodingException {\n    String[] pairs = StringUtils.split(query, '&');\n    Map<String, String> parameters = new HashMap<>();","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java#L450-L486","documentation":"Thrown when the raw request body (all posted parameters combined) exceeds the server's hard maximum length. This is a protective limit to prevent out-of-memory conditions from oversized uploads; it is independent of the configurable maxTextLength for the text itself.","triggerScenarios":"POST body larger than generousMaxLength (requestSizeLimit), e.g. a text parameter with hundreds of MB, or many/large parameters combined.","commonSituations":"Submitting very large documents in a single request, batch jobs sending unbounded text, clients retrying and concatenating payloads, or misconfigured requestSizeLimit that overflows to a low value.","solutions":["Reduce the submitted text size or split it into chunks below the server's limit","Increase the server's --requestLimit (request size) setting if larger payloads are legitimate","Check the client for accidental duplicate/concatenated payloads on retries"],"exampleFix":"// before\nPOST /v2/check with text=<10GB document>\n// after\nPOST /v2/check with text=<first 50KB chunk>, repeat per chunk","handlingStrategy":"validation","validationCode":"const MAX = 100 * 1024 * 1024; // match server requestSizeLimit\nconst body = new URLSearchParams({ text, language });\nif (body.toString().length > MAX) throw new Error('Payload exceeds server hard limit; chunk the text');","typeGuard":null,"tryCatchPattern":"try {\n  return await check(text);\n} catch (e) {\n  if (e.message.includes('hard limit')) {\n    return Promise.all(chunkText(text).map(check)); // split and retry\n  }\n  throw e;\n}","preventionTips":["Chunk large documents before sending","Set client-side max payload checks matching the server config","Avoid retry loops that resend oversized bodies"],"tags":["http","languagetool","payload-too-large"],"backgroundTag":"payload-too-large","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}