Anuken/Mindustry · error · RuntimeException
Objectives bytes too long:
Error message
Objectives bytes too long:
What it means
readObjectives() reads JSON-serialized MapObjectives. It reads a 4-byte length and throws RuntimeException if length >= 60_000 bytes. It bounds map-objective payloads (sent with map state) against memory abuse.
Source
Thrown at core/src/mindustry/io/TypeIO.java:942
public static Rules readRules(Reads read){
int length = read.i();
//this is only called clientside, but the byte limit is reasonable either way...
if(length > 100_000) throw new ArcRuntimeException("Rules too long");
String string = new String(read.b(new byte[length]), charset);
return JsonIO.read(Rules.class, string);
}
public static void writeObjectives(Writes write, MapObjectives executor){
String string = JsonIO.write(executor);
byte[] bytes = string.getBytes(charset);
write.i(bytes.length);
write.b(bytes);
}
public static MapObjectives readObjectives(Reads read){
int length = read.i();
if(length >= 60_000) throw new RuntimeException("Objectives bytes too long: " + length);
String string = new String(read.b(new byte[length]), charset);
return JsonIO.read(MapObjectives.class, string);
}
public static void writeObjectiveMarker(Writes write, ObjectiveMarker marker){
String string = JsonIO.json.toJson(marker, MapObjectives.ObjectiveMarker.class);
byte[] bytes = string.getBytes(charset);
write.i(bytes.length);
write.b(bytes);
}
public static ObjectiveMarker readObjectiveMarker(Reads read){
int length = read.i();
if(length > maxByteArraySize) throw new ArcRuntimeException("Objective marker too long");
String string = new String(read.b(new byte[length]), charset);
return JsonIO.read(MapObjectives.ObjectiveMarker.class, string);
}
View on GitHub (pinned to f695ad7e60)
Solutions
- Reduce the number and complexity of map objectives so JSON stays under 60KB.
- Split large objective state across multiple markers or out-of-band.
Defensive patterns
Strategy: validation
Validate before calling
// Before writing objectives, check serialized size against the read cap.
String json = JsonIO.write(executor);
if(json.getBytes(java.nio.charset.StandardCharsets.UTF_8).length >= 60_000){
throw new IllegalStateException("Objectives JSON too large");
} Try / catch
try { MapObjectives o = TypeIO.readObjectives(read); }
catch(RuntimeException e){ Log.err("Objectives payload too large", e); /* handle */ } Prevention
- Keep map-objective JSON under 60KB.
- Avoid huge objective graphs in custom maps.
When it happens
Trigger: A map-objectives packet whose int length field is >= 60_000.
Common situations: A map with very many objectives; a custom campaign map; corruption; a malicious source.
Related errors
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/d92ae58916f847cc.
Report an issue: GitHub.