{"record":{"id":"cd071b7533dfe7c9","repo":"Anuken/Mindustry","slug":"array-size-too-large","errorCode":null,"errorMessage":"Array size too large: {}","messagePattern":"Array size too large: (.+?)","errorType":"validation","errorClass":"ArcRuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/io/TypeIO.java","lineNumber":64,"sourceCode":"            write.b((byte)0);\n        }else if(object instanceof Integer i){\n            write.b((byte)1);\n            write.i(i);\n        }else if(object instanceof Long l){\n            write.b((byte)2);\n            write.l(l);\n        }else if(object instanceof Float f){\n            write.b((byte)3);\n            write.f(f);\n        }else if(object instanceof String s){\n            write.b((byte)4);\n            writeString(write, s);\n        }else if(object instanceof Content map){\n            write.b((byte)5);\n            write.b((byte)map.getContentType().ordinal());\n            write.s(map.id);\n        }else if(object instanceof IntSeq arr){\n            if(arr.size > maxArraySize) throw new ArcRuntimeException(\"Array size too large: \" + arr.size);\n            write.b((byte)6);\n            write.s((short)arr.size);\n            for(int i = 0; i < arr.size; i++){\n                write.i(arr.items[i]);\n            }\n        }else if(object instanceof Point2 p){\n            write.b((byte)7);\n            write.i(p.x);\n            write.i(p.y);\n        }else if(object instanceof Point2[] p){\n            //255 is the limit here, because it's a byte for some reason\n            if(p.length > 255) throw new ArcRuntimeException(\"Array size too large: \" + p.length);\n            write.b((byte)8);\n            write.b(p.length);\n            for(Point2 point2 : p){\n                write.i(point2.pack());\n            }\n        }else if(object instanceof TechNode map){","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/io/TypeIO.java#L46-L82","documentation":"TypeIO.writeObject rejects an IntSeq whose size exceeds maxArraySize (1000) before serializing it. This is a hard cap on object-typed IntSeq payloads used for build-plan configs and logic/network arguments. An ArcRuntimeException is thrown at write time, before any bytes are emitted, so no partial packet is produced.","triggerScenarios":"writeObject is invoked with an IntSeq > 1000 elements; commonly when a BuildPlan.config is a huge IntSeq (e.g. a processor's large link list, or a sorter config), serialized over the network or into a save via writeClientPlans/writePlans/writeObject.","commonSituations":"A logic processor or configuration producing an oversized IntSeq; a client plan with too many entries; passing user-controlled arrays into TypeIO.writeObject without sizing.","solutions":["Cap the IntSeq size before passing it as a config: split into chunks of <= 1000 or downsample.","If the data legitimately needs more than 1000 ints, store it out-of-band (a custom chunk via SaveVersion.addCustomChunk) rather than through writeObject.","For networked configs, apply getMaxPlans-style limiting on the producer side.","Validate size with arr.size <= TypeIO limit before constructing the plan."],"exampleFix":"// before\nplan.config = largeIntSeq; // size > 1000 -> ArcRuntimeException at write\n\n// after\nif (largeIntSeq.size > 1000) {\n    throw new IllegalArgumentException(\"IntSeq config exceeds network limit (1000): \" + largeIntSeq.size);\n}\nplan.config = largeIntSeq;","handlingStrategy":"validation","validationCode":"static final int MAX = 1000;\nvoid setIntSeqConfig(BuildPlan plan, IntSeq seq) {\n    if (seq.size > MAX) throw new IllegalArgumentException(\"IntSeq too large: \" + seq.size);\n    plan.config = seq;\n}","typeGuard":"static boolean intSeqWithinLimit(IntSeq s) { return s != null && s.size <= 1000; }","tryCatchPattern":"try {\n    TypeIO.writeObject(write, seq);\n} catch (ArcRuntimeException e) {\n    // size over limit; trim or reject before retrying\n}","preventionTips":["Cap IntSeq configs at 1000 elements on the producer side.","Use custom chunks for oversized persistent data.","Validate sizes before assigning to BuildPlan.config."],"tags":["network","serialization","typeio","size-limit","config"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}