Anuken/Mindustry · error · ArcRuntimeException
Too many long strings in MenuResult, reduce your amount of e
Error message
Too many long strings in MenuResult, reduce your amount of elements/IDs.
What it means
readMenuResult() enforces a global character budget (MenuResult.maxTotalStringLen = 6000) shared across all keys and string values. Before reading each key it checks remainingChars <= 0 and throws. This bounds total string memory per menu result.
Source
Thrown at core/src/mindustry/io/TypeIO.java:327
public static MenuResult readMenuResult(Reads read){
MenuResult result = new MenuResult();
result.token = read.l();
//would be nice to count bytes but sadly that's not really viable here
int remainingChars = MenuResult.maxTotalStringLen;
byte exists = read.b();
if(exists != 0){
result.result = read.str(MenuResult.maxResultLen);
remainingChars -= result.result.length();
} //else, no result, remains null
int entries = read.us();
if(entries > MenuResult.maxTotalValues) throw new ArcRuntimeException("UI result entry count exceeds max entries: " + entries);
for(int i = 0; i < entries; i++){
if(remainingChars <= 0) throw new ArcRuntimeException("Too many long strings in MenuResult, reduce your amount of elements/IDs.");
String key = read.str(Math.min(remainingChars, MenuResult.maxValueLen));
remainingChars -= key.length();
byte type = read.b();
switch(type){
case 0 -> result.values.put(key, read.f());
case 1 -> result.values.put(key, read.bool());
case 2 -> {
if(remainingChars <= 0) throw new ArcRuntimeException("Too many long strings in MenuResult, reduce your amount of elements/IDs.");
String value = read.str(Math.min(remainingChars, MenuResult.maxValueLen));
remainingChars -= value.length();
result.values.put(key, value);
}
default -> throw new ArcRuntimeException("Unknown UI entry type: " + type);
}
}
return result;View on GitHub (pinned to f695ad7e60)
Solutions
- Shorten keys and reduce the number of entries so total chars stay under 6000.
- Use compact key names in the UI builder.
Defensive patterns
Strategy: validation
Validate before calling
// Budget total key characters before sending a menu result.
int total = 0;
for(var k : menuResult.values.keys()) total += k.length();
if(total > MenuResult.maxTotalStringLen){
throw new IllegalStateException("Menu keys too long: " + total);
} Try / catch
try { MenuResult r = TypeIO.readMenuResult(read); }
catch(ArcRuntimeException e){ Log.err("Bad menu result", e); con.kick("Invalid menu result."); } Prevention
- Keep total key+value characters under 6000 per menu.
- Prefer short, compact key names.
When it happens
Trigger: The cumulative length of menu-result keys (plus any prior strings) reaches or exceeds 6000 chars before a key is read.
Common situations: A menu with many or long element IDs/keys; a mod generating verbose keys; a malicious client.
Related errors
- UI result entry count exceeds max entries:
- Unknown UI entry type:
- Nested arrays are not allowed
- Invalid array size: {}
- Invalid array size:
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/21d17e12ae393f41.
Report an issue: GitHub.