Anuken/Mindustry · error · IllegalArgumentException

Unit commands must be strings.

Error message

Unit commands must be strings.

What it means

Thrown by the UnitCommand parser when data is not a string (object, number, array, or boolean). The parser only resolves commands by name string; any other JSON type is rejected before lookup.

Source

Thrown at core/src/mindustry/mod/ContentParser.java:164

                StatusEffect result = locate(ContentType.status, data.asString());
                if(result != null) return result;
                throw new IllegalArgumentException("Unknown status effect: '" + data.asString() + "'");
            }
            StatusEffect effect = new StatusEffect((currentMod == null ? null : currentMod.name + "-") + data.getString("name"));
            effect.minfo.mod = currentMod;
            readFields(effect, data);
            return effect;
        });
        put(UnitCommand.class, (type, data) -> {
            if(data.isString()){
               var cmd = content.unitCommand(data.asString());
               if(cmd != null){
                   return cmd;
               }else{
                   throw new IllegalArgumentException("Unknown unit command name: " + data.asString());
               }
            }else{
                throw new IllegalArgumentException("Unit commands must be strings.");
            }
        });
        put(UnitStance.class, (type, data) -> {
            if(data.isString()){
                var cmd = content.unitStance(data.asString());
                if(cmd != null){
                    return cmd;
                }else{
                    throw new IllegalArgumentException("Unknown unit stance name: " + data.asString());
                }
            }else{
                throw new IllegalArgumentException("Unit stances must be strings.");
            }
        });
        put(BulletType.class, (type, data) -> {
            if(data.isString()){
                return field(Bullets.class, data);
            }else if(data.isArray()){

View on GitHub (pinned to f695ad7e60)

Solutions

  1. Provide the command as a quoted string.
  2. Use a command name that is registered in the current version.

Example fix

// before
"command": 3
// after
"command": "moveTo"
Defensive patterns

Strategy: type-guard

Type guard

// Guard: unit command value must be a JSON string.
boolean isCommandRef(JsonValue v) { return v.isString(); }

Prevention

When it happens

Trigger: A mod JSON supplies a unit command field as a non-string value, e.g. a number or an object {type: ...}.

Common situations: Forgetting quotes around the command name, or mistakenly using the object syntax that only some other parsers accept.

Related errors


AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14). Data as JSON: /api/errors/f933c5ecf9642e5d. Report an issue: GitHub.