{"record":{"id":"248c483143e43349","repo":"Anuken/Mindustry","slug":"sectorpresets-must-have-a-sector-number","errorCode":null,"errorMessage":"SectorPresets must have a sector number.","messagePattern":"SectorPresets must have a sector number\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/ContentParser.java","lineNumber":756,"sourceCode":"                    });\n                }\n            });\n\n            return status;\n        },\n        ContentType.sector, (TypeParser<SectorPreset>)(mod, name, value) -> {\n            readBundle(ContentType.sector, name, value);\n            if(value.isString()){\n                return locate(ContentType.sector, name);\n            }\n\n            SectorPreset preset;\n            SectorPreset found = allowPatching ? locate(ContentType.sector, name) : null;\n\n            if(found != null){\n                preset = found;\n            }else{\n                if(!value.has(\"sector\") || !value.get(\"sector\").isNumber()) throw new RuntimeException(\"SectorPresets must have a sector number.\");\n\n                preset = new SectorPreset(mod + \"-\" + name, currentMod);\n            }\n\n            currentContent = preset;\n            read(() -> {\n                Planet planet = preset.planet == null ? Planets.serpulo : preset.planet;\n                if(value.has(\"planet\")){\n                    planet = locate(ContentType.planet, value.getString(\"planet\", \"serpulo\"));\n\n                    if(planet == null) throw new RuntimeException(\"Planet '\" + value.getString(\"planet\") + \"' not found.\");\n                }\n\n                if(value.has(\"sector\")){\n                    //clear old value\n                    Sector prev = preset.sector;\n                    if(prev != null && prev.preset == preset){\n                        prev.preset = null;","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/ContentParser.java#L738-L774","documentation":"When creating a new SectorPreset (not patching an existing one), the JSON must contain a numeric \"sector\" field identifying which sector slot on the planet the preset occupies. Missing the key or supplying a non-number aborts preset creation before the Planet is even looked up.","triggerScenarios":"A sector preset JSON omits \"sector\", or sets it to a string/boolean. The guard is !value.has(\"sector\") || !value.get(\"sector\").isNumber().","commonSituations":"Forgetting the sector index; copy-pasting a preset and not updating the number; confusing \"sector\" with the preset's own name.","solutions":["Add a numeric \"sector\" field, e.g. \"sector\": 5.","Ensure the value is an integer within the planet's sector count (it is taken modulo planet.sectors.size later, but must be a number here).","If patching an existing preset, confirm allowPatching is on and the preset already exists (then the branch is skipped)."],"exampleFix":"// before\n\"sector\": \"five\"\n// after\n\"sector\": 5","handlingStrategy":"validation","validationCode":"if(!value.has(\"sector\") || !value.get(\"sector\").isNumber()){\n    throw new IllegalStateException(\"SectorPreset must include a numeric 'sector' field\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include an integer \"sector\" in new preset JSON.","For patches, ensure allowPatching and an existing preset."],"tags":["mindustry","modding","json","content-parser","sector-preset","validation"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}