{"record":{"id":"6c3d2902978b23a3","repo":"Anuken/Mindustry","slug":"rules-too-long","errorCode":null,"errorMessage":"Rules too long","messagePattern":"Rules too long","errorType":"exception","errorClass":"ArcRuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/io/TypeIO.java","lineNumber":928,"sourceCode":"    public static void writeMarkerControl(Writes write, LMarkerControl reason){\n        write.b((byte)reason.ordinal());\n    }\n\n    public static LMarkerControl readMarkerControl(Reads read){\n        return LMarkerControl.all[read.ub()];\n    }\n\n    public static void writeRules(Writes write, Rules rules){\n        String string = JsonIO.write(rules);\n        byte[] bytes = string.getBytes(charset);\n        write.i(bytes.length);\n        write.b(bytes);\n    }\n\n    public static Rules readRules(Reads read){\n        int length = read.i();\n        //this is only called clientside, but the byte limit is reasonable either way...\n        if(length > 100_000) throw new ArcRuntimeException(\"Rules too long\");\n        String string = new String(read.b(new byte[length]), charset);\n        return JsonIO.read(Rules.class, string);\n    }\n\n    public static void writeObjectives(Writes write, MapObjectives executor){\n        String string = JsonIO.write(executor);\n        byte[] bytes = string.getBytes(charset);\n        write.i(bytes.length);\n        write.b(bytes);\n    }\n\n    public static MapObjectives readObjectives(Reads read){\n        int length = read.i();\n        if(length >= 60_000) throw new RuntimeException(\"Objectives bytes too long: \" + length);\n        String string = new String(read.b(new byte[length]), charset);\n        return JsonIO.read(MapObjectives.class, string);\n    }\n","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/io/TypeIO.java#L910-L946","documentation":"readRules() reads JSON-serialized Rules from a Reads stream. It reads a 4-byte length and throws ArcRuntimeException if it exceeds 100_000 bytes. The cap protects the client (rules arrive on connect) from a hostile or buggy server's oversized payload.","triggerScenarios":"A rules packet whose int length field exceeds 100_000.","commonSituations":"A heavily customized gamemode or mod that inflates Rules JSON; a malicious server; corruption.","solutions":["Reduce rules complexity/mods so serialized Rules stays under 100KB.","If you are the client hitting this on a server you do not control, the server is hostile or buggy — leave the server."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before writing rules, check serialized size against the read cap.\nString json = JsonIO.write(rules);\nif(json.getBytes(java.nio.charset.StandardCharsets.UTF_8).length > 100_000){\n    throw new IllegalStateException(\"Rules JSON too large\");\n}","typeGuard":null,"tryCatchPattern":"try { Rules r = TypeIO.readRules(read); }\ncatch(ArcRuntimeException e){ Log.err(\"Rules payload too large\", e); /* disconnect from server */ }","preventionTips":["Audit rules fields a mod adds; keep serialized size under 100KB.","Treat an oversized rules payload from an unknown server as hostile."],"tags":["network","rules","deserialization","security"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}