{"record":{"id":"4b00fe7ee106ff43","repo":"apache/incubator-seata","slug":"dataname-data-is-too-large-size-length","errorCode":null,"errorMessage":"{dataName} data is too large, size={length}","messagePattern":"(.+?) data is too large, size=(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/seata/common/util/StringUtils.java","lineNumber":374,"sourceCode":"    /**\n     * check string data size\n     *\n     * @param data the str\n     * @param dataName the data name\n     * @param errorSize throw exception if size > errorSize\n     * @return boolean\n     */\n    public static boolean checkDataSize(String data, String dataName, int errorSize, boolean throwIfErr) {\n        if (isBlank(data)) {\n            return true;\n        }\n        int length = data.getBytes(StandardCharsets.UTF_8).length;\n        if (length > errorSize) {\n            LOGGER.warn(\"{} data is large(errorSize), size={}\", dataName, length);\n            if (!throwIfErr) {\n                return false;\n            }\n            throw new IllegalArgumentException(dataName + \" data is too large, size=\" + length);\n        }\n        return true;\n    }\n\n    public static boolean hasLowerCase(String str) {\n        if (null == str) {\n            return false;\n        }\n        for (int i = 0; i < str.length(); i++) {\n            if (Character.isLowerCase(str.charAt(i))) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n    public static boolean hasUpperCase(String str) {\n        if (null == str) {","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/util/StringUtils.java#L356-L392","documentation":"Thrown by StringUtils.checkDataSize when a checked data field (e.g. transaction context, xid, or application metadata serialized into protocol messages) exceeds errorSize bytes when UTF-8 encoded, and throwIfErr is true. It exists to stop oversized payloads from corrupting or bloating protocol frames; below the threshold the method only logs a warning.","triggerScenarios":"Passing a String to checkDataSize(data, dataName, errorSize, true) whose UTF-8 byte length exceeds errorSize. Typical callers validate applicationId/transaction service group/xid or user context payloads before encoding them into Seata protocol messages.","commonSituations":"Very long transactionServiceGroup or application names; oversized xid produced by custom coordinators; large business data stuffed into BusinessActionContext; multi-byte (CJK) content inflating byte length beyond the character count a developer estimated.","solutions":["Shrink the offending field identified by dataName in the message (e.g. shorten applicationId, transaction group, or context keys).","If the data is legitimately large, move it out of the transaction metadata and reference it by ID instead.","Raise the configured limit only if you control both client and server and understand the frame-size impact.","Remember the check is on UTF-8 bytes, not characters — non-ASCII text counts 2-4x."],"exampleFix":"// before: stuffing a whole payload into the action context\ncontext.put(\"payload\", hugeJsonString); // triggers checkDataSize failure\n\n// after: pass a reference instead\nString payloadId = payloadStore.save(hugeJsonString);\ncontext.put(\"payloadId\", payloadId);","handlingStrategy":"validation","validationCode":"boolean ok = StringUtils.checkDataSize(data, dataName, errorSize, false); // never throws\nif (!ok) {\n    // shrink, externalize, or reject the payload explicitly\n}","typeGuard":null,"tryCatchPattern":"try {\n    StringUtils.checkDataSize(data, dataName, errorSize, true);\n} catch (IllegalArgumentException e) {\n    throw new BusinessException(dataName + \" exceeds \" + errorSize + \" UTF-8 bytes\", e);\n}","preventionTips":["Call checkDataSize with throwIfErr=false first when you want to handle oversize gracefully.","Size-check on UTF-8 bytes, not String.length() — CJK characters cost 3 bytes each.","Keep transaction metadata (xid, group, context keys) small; pass large payloads by reference."],"tags":["validation","payload-size","configuration","protocol"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}