{"record":{"id":"7ec70c6763b9ce64","repo":"quarkusio/quarkus","slug":"type-fieldtype-should-be-handled-by-the-switch","errorCode":null,"errorMessage":"Type {fieldType} 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/JacksonDeserializerFactory.java","lineNumber":1112,"sourceCode":"            case \"int\" ->\n                isValueNullFalse.invokeVirtualMethod(ofMethod(JsonNode.class, \"asInt\", int.class),\n                        valueNode);\n            case \"java.lang.Integer\" ->\n                isValueNullFalse.invokeStaticMethod(ofMethod(Integer.class, \"valueOf\", Integer.class, int.class),\n                        isValueNullFalse.invokeVirtualMethod(ofMethod(JsonNode.class, \"asInt\", int.class),\n                                valueNode));\n            case \"long\", \"java.lang.Long\" ->\n                isValueNullFalse.invokeVirtualMethod(ofMethod(JsonNode.class, \"asLong\", long.class),\n                        valueNode);\n            case \"float\", \"java.lang.Float\" -> isValueNullFalse\n                    .convertPrimitive(\n                            isValueNullFalse.invokeVirtualMethod(ofMethod(JsonNode.class, \"asDouble\", double.class), valueNode),\n                            float.class);\n            case \"double\", \"java.lang.Double\" -> isValueNullFalse\n                    .invokeVirtualMethod(ofMethod(JsonNode.class, \"asDouble\", double.class), valueNode);\n            case \"boolean\", \"java.lang.Boolean\" -> isValueNullFalse\n                    .invokeVirtualMethod(ofMethod(JsonNode.class, \"asBoolean\", boolean.class), valueNode);\n            default -> throw new IllegalStateException(\"Type \" + fieldType + \" should be handled by the switch\");\n        };\n\n        isValueNullFalse.assign(result, convertedValue);\n\n        return result;\n    }\n\n    @Override\n    protected Optional<MethodInfo> findConstructor(ClassInfo classInfo) {\n        Optional<MethodInfo> ctorOpt = super.findConstructor(classInfo);\n        if (ctorOpt.isPresent() && ctorOpt.get().parametersCount() == 0 && !classInfo.isRecord()) {\n            Set<String> unsettableFields = findUnsettableFields(classInfo);\n            if (!unsettableFields.isEmpty()) {\n                return classInfo.constructors().stream()\n                        .filter(ctor -> Modifier.isPublic(ctor.flags()) && ctorCoversFields(ctor, unsettableFields))\n                        .findFirst();\n            }\n        }","sourceCodeStart":1094,"sourceCodeEnd":1130,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-jackson/deployment/src/main/java/io/quarkus/resteasy/reactive/jackson/deployment/processor/JacksonDeserializerFactory.java#L1094-L1130","documentation":"During Quarkus's build-time generation of a custom Jackson deserializer, generated bytecode converts a JSON tree node into a primitive/simple-typed field value via a switch over the field's type name. The switch only covers String, char/Character, short/Short, int/Integer, long/Long, float/Float, double/Double and boolean/Boolean. If some other type reaches this primitive-conversion path, the deployment fails with an IllegalStateException, indicating an internal assumption was broken rather than a user-facing API misuse.","triggerScenarios":"A resource class field with a primitive/wrapper-ish type outside the supported set ends up on the primitive-field deserialization code path in JacksonDeserializerFactory (typically a byte/Byte, BigDecimal or similar field in a @CustomDeserialization-generated deserializer, or an internal regression).","commonSituations":"Using unusual field types like byte, Byte or java.math.BigDecimal in DTOs processed by the generated-deserializer feature; upgrading Quarkus and a previously working DTO trips a newly uncovered path; mixing Jackson custom serialization annotations with non-standard scalar field types.","solutions":["Inspect the field type named in the message and change it to a supported scalar (String, int/Integer, long/Long, double/Double, float/Float, boolean/Boolean, short/Short, char/Character)","Convert unsupported scalar fields (e.g. byte/Byte, BigDecimal) to a supported type or use a plain Jackson deserializer (@JsonDeserialize/@JsonProperty with custom deserializer) instead of the generated one","Check your Quarkus version; if the type is a standard scalar and still fails, report a Quarkus issue with the failing class","Work around by disabling the generated custom deserialization (remove @CustomDeserialization / related config) so stock Jackson handles the type"],"exampleFix":"// before\nclass Dto { private byte flags; }\n\n// after\nclass Dto { private int flags; } // or use a Jackson @JsonDeserialize on the field","handlingStrategy":"validation","validationCode":"Set<String> supported = Set.of(\"java.lang.String\",\"char\",\"java.lang.Character\",\"short\",\"java.lang.Short\",\"int\",\"java.lang.Integer\",\"long\",\"java.lang.Long\",\"float\",\"java.lang.Float\",\"double\",\"java.lang.Double\",\"boolean\",\"java.lang.Boolean\");\nfor (Field f : Dto.class.getDeclaredFields()) {\n    if (!supported.contains(f.getType().getName()))\n        throw new IllegalStateException(\"Field \" + f + \" not supported by generated Jackson deserializer\");\n}","typeGuard":"static boolean isSupportedScalar(Type t) {\n    String n = t.getTypeName();\n    return n.equals(\"java.lang.String\") || n.equals(\"int\") || n.equals(\"java.lang.Integer\")\n        || n.equals(\"long\") || n.equals(\"java.lang.Long\") || n.equals(\"double\") || n.equals(\"java.lang.Double\")\n        || n.equals(\"float\") || n.equals(\"java.lang.Float\") || n.equals(\"boolean\") || n.equals(\"java.lang.Boolean\")\n        || n.equals(\"short\") || n.equals(\"java.lang.Short\") || n.equals(\"char\") || n.equals(\"java.lang.Character\");\n}","tryCatchPattern":"try {\n    applicationResult = quarkusBuild();\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"should be handled by the switch\")) {\n        // fall back to stock Jackson deserialization for the offending DTO\n    }\n}","preventionTips":["Keep DTO fields to common scalars and wrapper types","Use standard Jackson annotations instead of generated custom (de)serializers for exotic types","Run a full build after upgrading Quarkus to catch new gaps early","Pin DTOs with unusual fields behind their own converters"],"tags":["jackson","quarkus","build-time","deserialization"],"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"}