{"record":{"id":"f933c5ecf9642e5d","repo":"Anuken/Mindustry","slug":"unit-commands-must-be-strings","errorCode":null,"errorMessage":"Unit commands must be strings.","messagePattern":"Unit commands must be strings\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/ContentParser.java","lineNumber":164,"sourceCode":"                StatusEffect result = locate(ContentType.status, data.asString());\n                if(result != null) return result;\n                throw new IllegalArgumentException(\"Unknown status effect: '\" + data.asString() + \"'\");\n            }\n            StatusEffect effect = new StatusEffect((currentMod == null ? null : currentMod.name + \"-\") + data.getString(\"name\"));\n            effect.minfo.mod = currentMod;\n            readFields(effect, data);\n            return effect;\n        });\n        put(UnitCommand.class, (type, data) -> {\n            if(data.isString()){\n               var cmd = content.unitCommand(data.asString());\n               if(cmd != null){\n                   return cmd;\n               }else{\n                   throw new IllegalArgumentException(\"Unknown unit command name: \" + data.asString());\n               }\n            }else{\n                throw new IllegalArgumentException(\"Unit commands must be strings.\");\n            }\n        });\n        put(UnitStance.class, (type, data) -> {\n            if(data.isString()){\n                var cmd = content.unitStance(data.asString());\n                if(cmd != null){\n                    return cmd;\n                }else{\n                    throw new IllegalArgumentException(\"Unknown unit stance name: \" + data.asString());\n                }\n            }else{\n                throw new IllegalArgumentException(\"Unit stances must be strings.\");\n            }\n        });\n        put(BulletType.class, (type, data) -> {\n            if(data.isString()){\n                return field(Bullets.class, data);\n            }else if(data.isArray()){","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/ContentParser.java#L146-L182","documentation":"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.","triggerScenarios":"A mod JSON supplies a unit command field as a non-string value, e.g. a number or an object {type: ...}.","commonSituations":"Forgetting quotes around the command name, or mistakenly using the object syntax that only some other parsers accept.","solutions":["Provide the command as a quoted string.","Use a command name that is registered in the current version."],"exampleFix":"// before\n\"command\": 3\n// after\n\"command\": \"moveTo\"","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Guard: unit command value must be a JSON string.\nboolean isCommandRef(JsonValue v) { return v.isString(); }","tryCatchPattern":null,"preventionTips":["Always quote command name strings.","Do not use object syntax for command references.","Validate JSON value types with a linter."],"tags":["modding","json","content-parser","unit-command"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}