Anuken/Mindustry · error · IllegalArgumentException
name is null
Error message
name is null
What it means
Thrown by the GenRegion constructor when name is null. GenRegion extends AtlasRegion and stores the name to identify a sprite region in the packing pipeline; a null name is treated as a programmer error, not user input, so it fails fast with IllegalArgumentException. This guard runs only inside the build-time ImagePacker tool, never in shipped game code.
Source
Thrown at tools/src/mindustry/tools/ImagePacker.java:293
replace(((GenRegion)region).name, image);
}
static void err(String message, Object... args){
throw new IllegalArgumentException(Strings.format(message, args));
}
static void validate(TextureRegion region){
if(((GenRegion)region).invalid){
ImagePacker.err("Region does not exist: @", ((GenRegion)region).name);
}
}
static class GenRegion extends AtlasRegion{
boolean invalid;
Fi path;
GenRegion(String name, Fi path){
if(name == null) throw new IllegalArgumentException("name is null");
this.name = name;
this.path = path;
}
@Override
public boolean found(){
return !invalid;
}
}
static class PackIndex{
@Nullable AtlasRegion region;
@Nullable Pixmap pixmap;
Fi file;
public PackIndex(Fi file){
this.file = file;
}View on GitHub (pinned to f695ad7e60)
Solutions
- Trace the caller of 'new GenRegion(...)' and ensure the name argument is always a non-null, non-empty string.
- If the name is derived from a file path, fall back to path.nameWithoutExtension() instead of passing null.
- Add a unit test that constructs every region declared in pack.json and asserts a non-null name.
- Fail earlier in the pipeline with a descriptive message naming the offending asset.
Example fix
// before
gen = new GenRegion(name, file); // name may be null
// after
String regionName = name != null ? name : file.nameWithoutExtension();
if(regionName == null || regionName.isEmpty()) throw new IllegalStateException("Region has no name: " + file);
gen = new GenRegion(regionName, file); Defensive patterns
Strategy: validation
Validate before calling
// Before constructing a GenRegion
String regionName = name != null ? name : (path != null ? path.nameWithoutExtension() : null);
if(regionName == null || regionName.isEmpty()){
throw new IllegalStateException("Cannot create region with null name for path: " + path);
}
new GenRegion(regionName, path); Type guard
static boolean hasValidRegionName(String name, Fi path){
return name != null && !name.isEmpty() || (path != null && path.nameWithoutExtension() != null);
} Prevention
- Always derive the region name from the asset filename so it can never be null.
- Add a test that builds every region declared in pack.json and asserts a non-null name.
- Fail at the asset-loading boundary with a descriptive message rather than deep in the constructor.
When it happens
Trigger: Invoking new GenRegion(null, path), or calling code that derives the name from a file path whose name resolved to null (e.g. a sprite entry with no filename, or a region generator that returns null on a missing mapping).
Common situations: Adding a new sprite whose pack.json entry has no name; refactoring region generation so the name argument is dropped; a malformed/empty filename in the assets list feeding a null name; an upstream change to Fi naming returning null on an unusual path.
Related errors
- Image dimensions are not divisible by 4: {width}x{height}
- Data must be exactly 32 bytes (length: ${data.length})
- Max image size exceeded
- Cache file for asset {path} not found!
- Map has no cores!
AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14).
Data as JSON: /api/errors/536f9fc1912449e4.
Report an issue: GitHub.