{"record":{"id":"2c6c518ec9019eb0","repo":"quarkusio/quarkus","slug":"type-type-should-be-handled-by-the-switch","errorCode":null,"errorMessage":"Type {type} should be handled by the switch","messagePattern":"Type (.+?) should be handled by the switch","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializationUtils.java","lineNumber":63,"sourceCode":"        // to context.readTreeAsValue() which performs proper type validation.\n        return false;\n    }\n\n    static ResultHandle getDefaultValue(BytecodeCreator bytecodeCreator, Type type) {\n        if (type.kind() != Kind.PRIMITIVE) {\n            return bytecodeCreator.loadNull();\n        }\n\n        return switch (type.name().toString()) {\n            case \"byte\" -> bytecodeCreator.load(DEFAULT_BYTE);\n            case \"boolean\" -> bytecodeCreator.load(DEFAULT_BOOLEAN);\n            case \"char\" -> bytecodeCreator.load(DEFAULT_CHAR);\n            case \"double\" -> bytecodeCreator.load(DEFAULT_DOUBLE);\n            case \"float\" -> bytecodeCreator.load(DEFAULT_FLOAT);\n            case \"int\" -> bytecodeCreator.load(DEFAULT_INT);\n            case \"long\" -> bytecodeCreator.load(DEFAULT_LONG);\n            case \"short\" -> bytecodeCreator.load(DEFAULT_SHORT);\n            default -> throw new IllegalStateException(\"Type \" + type + \" should be handled by the switch\");\n        };\n    }\n}\n","sourceCodeStart":45,"sourceCodeEnd":67,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonSerializationUtils.java#L45-L67","documentation":"JacksonSerializationUtils.getDefaultValue generates bytecode that yields a type's default value (0, false, etc.) when a JSON node is null. It switches over primitive type names (byte?, char, double, float, int, long, short, boolean...); any type that reaches it outside the covered set throws IllegalStateException. This is a build/deployment-time failure of Quarkus's generated Jackson serializer/deserializer machinery, i.e. an internal coverage gap rather than a documented user API.","triggerScenarios":"A primitive-typed field whose default value must be generated is not covered by the switch (e.g. byte fields, or a new primitive path added upstream), reached while generating deserializer bytecode for a DTO class.","commonSituations":"DTOs with byte/byte[] or exotic primitive fields processed by the generated serializer; Quarkus upgrades exposing new paths; inconsistent switch coverage between getDefaultValue and its callers (e.g. JacksonDeserializerFactory).","solutions":["Change the offending field type to one supported by the switch (int, long, short, char, float, double, boolean, String, wrappers)","Avoid the generated code path by using standard Jackson annotations/deserializers for that DTO field","Check the Quarkus version and changelog; if a common primitive (e.g. byte) fails, file a Quarkus bug with a reproducer","Isolate the DTO and test compilation with -Dquickly to confirm which field triggers the gap"],"exampleFix":"// before\nclass Dto { private byte status; }\n\n// after\nclass Dto { private int status; }","handlingStrategy":"validation","validationCode":"Set<String> supported = Set.of(\"char\",\"double\",\"float\",\"int\",\"long\",\"short\",\"boolean\");\nfor (Field f : Dto.class.getDeclaredFields()) {\n    if (f.getType().isPrimitive() && !supported.contains(f.getType().getName()))\n        throw new IllegalStateException(\"Primitive field \" + f + \" lacks a generated default value\");\n}","typeGuard":"static boolean isSupportedPrimitive(Class<?> c) {\n    return c.isPrimitive() && !c.equals(byte.class) && !c.equals(void.class);\n}","tryCatchPattern":"try {\n    buildApplication();\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Type \")) {\n        // switch that DTO to standard Jackson handling\n    }\n}","preventionTips":["Avoid byte primitives in DTOs handled by generated serializers","Prefer wrapper types (Integer, Long) over primitives for exotic fields","Rebuild the whole app after Quarkus upgrades","Centralize DTO field types to a reviewed set"],"tags":["jackson","quarkus","build-time","bytecode-generation"],"backgroundTag":"unsupported-type-deserialization","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}