{"record":{"id":"04385205546fa822","repo":"HMCL-dev/HMCL","slug":"no-image-found","errorCode":null,"errorMessage":"No image found","messagePattern":"No image found","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java","lineNumber":100,"sourceCode":"        return HexFormat.of().formatHex(digest.digest());\n    }\n\n    private static void putInt(byte[] array, int offset, int x) {\n        array[offset + 0] = (byte) (x >> 24 & 0xff);\n        array[offset + 1] = (byte) (x >> 16 & 0xff);\n        array[offset + 2] = (byte) (x >> 8 & 0xff);\n        array[offset + 3] = (byte) (x >> 0 & 0xff);\n    }\n\n    public static Texture loadTexture(InputStream in) throws IOException {\n        if (in == null) return null;\n        Image img;\n        try (InputStream is = in) {\n            img = new Image(is);\n        }\n\n        if (img.isError()) {\n            throw new IOException(\"No image found\", img.getException());\n        }\n        return loadTexture(img);\n    }\n\n    public static Texture loadTexture(Image image) {\n        if (image == null) return null;\n\n        String hash = computeTextureHash(image);\n\n        Texture existent = textures.get(hash);\n        if (existent != null) {\n            return existent;\n        }\n\n        Texture texture = new Texture(hash, image);\n        existent = textures.putIfAbsent(hash, texture);\n\n        if (existent != null) {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/Texture.java#L82-L118","documentation":"Texture.loadTexture(InputStream) wraps the stream in a JavaFX Image and throws IOException(\"No image found\") when img.isError() reports the decoder failed. It means the provided bytes are not a decodable image (or are corrupt), so the skin/cape texture cannot be loaded.","triggerScenarios":"Calling Texture.loadTexture(InputStream) with an empty stream, non-image data (e.g. HTML error page, JSON), truncated PNG, or unsupported format that JavaFX cannot decode.","commonSituations":"Skin server returning 404/HTML instead of PNG; corrupted local skin cache files; user-selected file that is not a real PNG; interrupted downloads.","solutions":["Verify the input is a valid PNG image (open in an image viewer or check magic bytes) before loading.","Re-download the skin/texture from the source server and retry.","Check the wrapped img.getException() for the underlying decode cause and fix the data source accordingly.","Return null / use a default texture when loading optional skins fails."],"exampleFix":"// before\nTexture t = Texture.loadTexture(Files.newInputStream(path));\n// after\ntry (InputStream is = Files.newInputStream(path)) {\n    Texture t = Texture.loadTexture(is);\n    if (t == null) log.warning(\"Texture unreadable, using default skin\");\n}","handlingStrategy":"try-catch","validationCode":"// check magic bytes before decoding\nbyte[] head = new byte[8];\ntry (InputStream in = stream) {\n    if (in.read(head) != 8) throw new IOException(\"Texture stream too short\");\n    boolean isPng = (head[0] & 0xFF) == 0x89 && head[1] == 'P' && head[2] == 'N' && head[3] == 'G';\n    if (!isPng) throw new IOException(\"Not a PNG texture\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Texture t = Texture.loadTexture(inputStream);\n} catch (IOException e) {\n    // fall back to default skin, log img.getException() cause\n}","preventionTips":["Verify the texture URL returns HTTP 200 with image/* content type.","Check downloaded files' integrity (size/magic bytes) before caching.","Wrap optional skin loading in fallback-to-default logic."],"tags":["io","image","texture"],"backgroundTag":"invalid-argument-format","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}