{"record":{"id":"5dcb4aa31322fcd1","repo":"quarkusio/quarkus","slug":"unknown-image-format","errorCode":null,"errorMessage":"Unknown image format ","messagePattern":"Unknown image format ","errorType":"http","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"error","filePath":"integration-tests/awt/src/main/java/io/quarkus/awt/it/ImageResource.java","lineNumber":225,"sourceCode":"                case \"GIF\":\n                case \"PNG\":\n                    ImageIO.write(img, format, bos);\n                    break;\n                case \"JPG\":\n                case \"BMP\":\n                    // Doesn't handle transparency.\n                    final BufferedImage imgBGR = new BufferedImage(img.getWidth(), img.getHeight(), TYPE_3BYTE_BGR);\n                    imgBGR.getGraphics().drawImage(img, 0, 0, null);\n                    ImageIO.write(imgBGR, format, bos);\n                    break;\n                case \"WBMP\":\n                    // Handles neither transparency nor colours, it's monochrome.\n                    final BufferedImage imgBINARY = new BufferedImage(img.getWidth(), img.getHeight(), TYPE_BYTE_BINARY);\n                    imgBINARY.getGraphics().drawImage(img, 0, 0, null);\n                    ImageIO.write(imgBINARY, format, bos);\n                    break;\n                default:\n                    throw new IllegalArgumentException(\"Unknown image format \" + format);\n            }\n\n            return Response\n                    .accepted()\n                    .type(MediaType.APPLICATION_OCTET_STREAM_TYPE)\n                    .header(\"Content-Disposition\", \"attachment; filename=\\\"picture.\" + format.toLowerCase() + \"\\\"\")\n                    .entity(bos.toByteArray())\n                    .build();\n        }\n    }\n\n    @GET\n    @Produces(MediaType.TEXT_PLAIN)\n    @Path(\"/fonts\")\n    public Response fonts() {\n        return Response.ok().entity(Arrays.toString(\n                GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames())).build();\n    }","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/awt/src/main/java/io/quarkus/awt/it/ImageResource.java#L207-L243","documentation":"Thrown by ImageResource.image when the requested 'format' path/query parameter does not match any of the image formats handled by the switch statement (jpg, png, gif, bmp, binary, etc.). The default branch rejects any unsupported target format before writing via ImageIO.","triggerScenarios":"Calling the image endpoint with a format value not in the switch, e.g. format=tiff, format=webp, or a misspelled value like 'jepg'.","commonSituations":"Client using image formats Java ImageIO cannot write natively (TIFF pre-Java9 style assumptions, WebP); typos in the format parameter; case mismatches depending on how the parameter is normalized.","solutions":["Use one of the supported format values (jpg, png, gif, bmp, binary) for the endpoint.","Fix typos and match the casing the resource expects (e.g. 'jpeg' vs 'jpg' per the switch).","Extend the switch (or register an ImageIO SPI writer) if a new format is genuinely needed."],"exampleFix":"// before\nGET /image?format=webp\n// after\nGET /image?format=png","handlingStrategy":"validation","validationCode":"java.util.Set<String> SUPPORTED = java.util.Set.of(\"jpg\", \"png\", \"gif\", \"bmp\", \"binary\");\nif (!SUPPORTED.contains(format)) {\n    throw new IllegalArgumentException(\"format must be one of \" + SUPPORTED);\n}","typeGuard":"boolean isSupportedImageFormat(String f) {\n    return f != null && java.util.Set.of(\"jpg\", \"png\", \"gif\", \"bmp\", \"binary\").contains(f.toLowerCase());\n}","tryCatchPattern":"try {\n    Response r = target(\"/image/\" + format).get();\n} catch (jakarta.ws.rs.BadRequestException e) {\n    log.error(\"Unsupported image format requested: \" + format);\n}","preventionTips":["Keep a whitelist of format values shared between client and server.","Normalize/validate format input at the UI layer.","Check ImageIO.getWriterFormatNames() before adding new formats."],"tags":["imageio","awt","invalid-parameter"],"backgroundTag":"unsupported-format","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}