{"record":{"id":"30eb9ad4c8963d46","repo":"Anuken/Mindustry","slug":"map-name-cannot-be-empty-file","errorCode":null,"errorMessage":"Map name cannot be empty! File: ","messagePattern":"Map name cannot be empty! File: ","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/maps/Maps.java","lineNumber":483,"sourceCode":"        String name = Strings.sanitizeFilename(unsanitizedName);\n        if(name.isEmpty()) name = \"blank\";\n\n        Fi result = null;\n        int index = 0;\n\n        while(result == null || result.exists()){\n            result = customMapDirectory.child(name + (index == 0 ? \"\" : \"_\" + index) + \".\" + mapExtension);\n            index ++;\n        }\n\n        return result;\n    }\n\n    private Map loadMap(Fi file, boolean custom) throws IOException{\n        Map map = MapIO.createMap(file, custom);\n\n        if(map.name() == null){\n            throw new IOException(\"Map name cannot be empty! File: \" + file);\n        }\n\n        maps.add(map);\n        maps.sort();\n        return map;\n    }\n\n    public interface MapProvider{\n        @Nullable Map next(Gamemode mode, @Nullable Map previous);\n    }\n\n    public enum ShuffleMode implements MapProvider{\n        none((mode, map) -> null),\n        all((mode, prev) -> next(mode, prev, Vars.maps.defaultMaps(), Vars.maps.customMaps())),\n        custom((mode, prev) -> next(mode, prev, Vars.maps.customMaps().isEmpty() ? Vars.maps.defaultMaps() : Vars.maps.customMaps())),\n        builtin((mode, prev) -> next(mode, prev, Vars.maps.defaultMaps()));\n\n        private final MapProvider provider;","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/maps/Maps.java#L465-L501","documentation":"Thrown by Maps.loadMap(Fi, boolean) after MapIO.createMap builds a Map from a file. If the resulting Map has a null name (no name metadata in the .msav), it is rejected with an IOException. Maps are expected to always carry a non-null name so they can be listed and referenced.","triggerScenarios":"Calling Maps.loadMap on a custom .msav file whose internal name field is null/empty; triggered during map import, shuffle-list rebuild, or server map scanning of customMapDirectory.","commonSituations":"Corrupted or partially-written .msav files, maps saved by an incompatible/older Mindustry version, hand-edited map files, or a map whose name was blanked in the editor before export.","solutions":["Remove or move the offending .msav out of the custom maps directory and re-export it from the editor with a real name.","Re-save the map in the editor ensuring the name field is non-empty before exporting.","Validate the file is a genuine Mindustry map and not truncated/corrupt."],"exampleFix":"// before: map file 'blank.msav' has empty name metadata -> loadMap throws\n// after: open in editor, set name 'My Map', re-export; loadMap succeeds","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Map m = maps.loadMap(file, true);\n} catch (IOException e) {\n    // name was null/empty or file unreadable; skip this file and log it\n    Log.err(\"Skipping invalid map file @: @\", file, e.getMessage());\n}","preventionTips":["Always set a non-empty name before exporting a map in the editor.","Scan customMapDirectory and skip files that fail a quick header/name check before full load.","Keep maps saved with a current game version to avoid metadata regressions."],"tags":["maps","io","custom-maps","loadmap"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}