{"record":{"id":"c004320a4b89f827","repo":"Anuken/Mindustry","slug":"cache-file-for-asset-path-not-found","errorCode":null,"errorMessage":"Cache file for asset {path} not found!","messagePattern":"Cache file for asset (.+?) not found!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/mindustry/mod/data/DataAsset.java","lineNumber":63,"sourceCode":"        return getType().folder + \"/\" + path;\n    }\n\n    /** @return for embedded assets, the data. Not implemented for non-embedded assets (use the cache file). */\n    public byte[] getData(){\n        throw new UnsupportedOperationException(\"Not implemented\");\n    }\n\n    public boolean isAlwaysEmbedded(){\n        return getType().embedded;\n    }\n\n    public boolean isCached(){\n        return overrideCacheFile != null || (stringHash != null && Vars.assetCache.has(stringHash));\n    }\n\n    public Fi getCacheFileNoNull(){\n        Fi file = getCacheFile();\n        if(file == null) throw new RuntimeException(\"Cache file for asset \" + path + \" not found!\");\n        return file;\n    }\n\n    public @Nullable Fi getCacheFile(){\n        return overrideCacheFile != null ? overrideCacheFile : Vars.assetCache.get(stringHash);\n    }\n\n    public void readFromZip(String path, Fi file){\n        if(isAlwaysEmbedded()) throw new UnsupportedOperationException(\"Always-embedded assets need custom implementations for reading.\");\n        setPath(path);\n        updateData(file.readBytes());\n    }\n\n    /** Reads this asset in from a file on disk, and makes its hash point to the specified file, instead of a new one in the cache folder. Only used on the server. */\n    public void readOverride(String path, Fi file) throws IOException{\n        setPath(path);\n        setHash(file.sha256());\n        this.overrideCacheFile = file;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/Anuken/Mindustry/blob/f695ad7e60323ebced984fa26d0bcf0bc54296b4/core/src/mindustry/mod/data/DataAsset.java#L45-L81","documentation":"DataAsset.getCacheFileNoNull returns the override cache file or the hash-indexed file from Vars.assetCache; if neither resolves (no override and hash absent from cache) it throws RuntimeException. Used when an asset is expected to be cached but the cache entry is missing.","triggerScenarios":"An asset is treated as cached but its stringHash is not present in the asset cache and no overrideCacheFile was set.","commonSituations":"Asset cache not generated/downloaded for the current build; hash mismatch after content changed; missing asset in a partial install; cache disabled or cleared.","solutions":["Ensure the asset cache is built/downloaded before requesting the asset.","Verify the asset's stringHash matches an existing cache entry.","Re-acquire or regenerate the asset bundle.","Confirm isCached() returns true before calling getCacheFileNoNull()."],"exampleFix":"// before\nFi f = asset.getCacheFileNoNull(); // throws if not cached\n\n// after\nif (asset.isCached()) {\n    Fi f = asset.getCacheFileNoNull();\n} else {\n    // trigger cache generation / download first\n}","handlingStrategy":"validation","validationCode":"// Only demand a cache file when one actually exists.\nif(!asset.isCached()) {\n    throw new IllegalStateException(\"Asset not cached, cannot resolve file: \" + asset.path);\n}\nFi f = asset.getCacheFileNoNull();","typeGuard":"boolean assetResolvable(DataAsset a){ return a != null && a.isCached(); }","tryCatchPattern":"try {\n    Fi f = asset.getCacheFileNoNull();\n} catch(RuntimeException e) {\n    if(e.getMessage().startsWith(\"Cache file for asset\")) { /* (re)build cache */ }\n    else throw e;\n}","preventionTips":["Call isCached() before getCacheFileNoNull().","Ensure the asset cache is generated/downloaded for the build.","Re-verify hashes when content changes."],"tags":["assets","cache","modding","validation"],"backgroundTag":null,"analyzedSha":"f695ad7e60323ebced984fa26d0bcf0bc54296b4","analyzedAt":"2026-08-14T04:31:16.262Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}