{"record":{"id":"f623c374e5d3145f","repo":"Anuken/Mindustry","slug":"unknown-save-version-are-you-trying-to-load-a-f623c3","errorCode":null,"errorMessage":"Unknown save version: {}. Are you trying to load a save from a newer version?","messagePattern":"Unknown save version: (.+?)\\. Are you trying to load a save from a newer version\\?","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/io/SaveIO.java","lineNumber":100,"sourceCode":"    }\n\n    public static SaveMeta getMeta(Fi file){\n        try{\n            return getMeta(getStream(file));\n        }catch(Throwable e){\n            Log.err(e);\n            return getMeta(getBackupStream(file));\n        }\n    }\n\n    public static SaveMeta getMeta(DataInputStream stream){\n\n        try{\n            readHeader(stream);\n            int version = stream.readInt();\n            SaveVersion ver = versions.get(version);\n\n            if(ver == null) throw new IOException(\"Unknown save version: \" + version + \". Are you trying to load a save from a newer version?\");\n\n            SaveMeta meta = ver.getMeta(stream);\n            stream.close();\n            return meta;\n        }catch(IOException e){\n            throw new RuntimeException(e);\n        }\n    }\n\n    public static Fi fileFor(int slot){\n        return saveDirectory.child(slot + \".\" + Vars.saveExtension);\n    }\n\n    public static Fi backupFileFor(Fi file){\n        return file.sibling(file.name() + \"-backup.\" + file.extension());\n    }\n\n    public static void write(Fi file, SaveOptions options){","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/io/SaveIO.java#L82-L118","documentation":"Raised by SaveIO.getMeta(DataInputStream) after reading the 4-byte version int and not finding it in the SaveIO.versions IntMap. The IOException is caught and rethrown as a RuntimeException, so callers see a RuntimeException whose cause is this message. The registered versions are Save1..Save13 (see SaveIO.java:23); any version int outside that set is rejected.","triggerScenarios":"SaveIO.getMeta(stream) when the int after the MSAV header does not map to a registered SaveVersion; commonly invoked via getMeta(Fi) (preview/validity check) which then also tries the backup file.","commonSituations":"Save created by a newer or beta build whose version int is higher than Save13; save created by a much older build whose version was removed; a manually crafted or partially overwritten file where the version bytes are random.","solutions":["Update the game to a build whose SaveIO.versionArray includes the version int printed in the message (match the build that wrote the save).","If downgrading, re-save in an intermediate compatible version first.","Catch RuntimeException around getMeta and present a 'save from a newer version' message to the user instead of crashing.","For preview UIs, use isSaveValid to filter unreadable files before calling getMeta."],"exampleFix":"// before\nSaveMeta meta = SaveIO.getMeta(stream);\n\n// after\nSaveMeta meta;\ntry {\n    meta = SaveIO.getMeta(stream);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        throw new IllegalStateException(\"Save is from an incompatible game version\", e);\n    }\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Check version before reading meta in bulk\ntry (DataInputStream s = SaveIO.getStream(file)) {\n    SaveIO.readHeader(s);\n    int v = s.readInt();\n    if (!SaveIO.versions.containsKey(v)) {\n        // unsupported version; skip this file\n    }\n}","typeGuard":"null","tryCatchPattern":"try {\n    SaveMeta meta = SaveIO.getMeta(stream);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException ioe) {\n        // version/header problem; report ioe.getMessage()\n    }\n}","preventionTips":["Use isSaveValid to filter saves in selection UIs before getMeta.","Match game build to the save's build before loading.","Surface the version int from the message to the user for triage."],"tags":["save-io","version-mismatch","deserialization"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}