quarkusio/quarkus · error · IllegalArgumentException

Unsupported primitive type in multipart form field: {field.d

Error message

Unsupported primitive type in multipart form field: {field.declaringClass}.{field.name}

What it means

When generating bytecode to convert a multipart form field value to a String part, Quarkus only supports a fixed set of primitive types (boolean, char, int, long, etc. that map to String.valueOf). Encountering an unhandled primitive kind in the switch's default branch means the field's primitive type is not supported for multipart encoding.

Source

Thrown at extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java:2464

                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, boolean.class), fieldValue);
            case CHAR:
                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, char.class), fieldValue);
            case DOUBLE:
                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, double.class), fieldValue);
            case FLOAT:
                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, float.class), fieldValue);
            case INT:
                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, int.class), fieldValue);
            case LONG:
                return methodCreator.invokeStaticMethod(
                        MethodDescriptor.ofMethod(String.class, "valueOf", String.class, long.class), fieldValue);
            default:
                throw new IllegalArgumentException("Unsupported primitive type in multipart form field: "
                        + field.declaringClass().name() + "." + field.name());
        }
    }

    private ResultHandle partFilenameHandle(BytecodeCreator methodCreator, String partFilename) {
        return partFilename != null ? methodCreator.load(partFilename) : methodCreator.loadNull();
    }

    private void addString(BytecodeCreator methodCreator, AssignableResultHandle multipartForm, String formParamName,
            String partType, String partFilename, ResultHandle fieldValue) {
        if (MediaType.APPLICATION_OCTET_STREAM.equalsIgnoreCase(partType)) {
            methodCreator.assign(multipartForm,
                    // MultipartForm#stringFileUpload(String name, String filename, String content, String mediaType);
                    methodCreator.invokeVirtualMethod(
                            MethodDescriptor.ofMethod(ClientMultipartForm.class, "stringFileUpload",
                                    ClientMultipartForm.class, String.class, String.class, String.class,
                                    String.class),
                            multipartForm,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Change the field to a wrapper type (Float, Double, Short) — wrappers are handled via the object path or String conversion
  2. Convert the field to String yourself in the form bean
  3. Use a supported primitive (int, long, boolean, char) if semantically acceptable

Example fix

// before
@RestForm
float ratio;
// after
@RestForm
String ratio; // or java.lang.Float
Defensive patterns

Strategy: validation

Validate before calling

static void validateNoExoticPrimitives(Class<?> formBean) {
    for (var f : formBean.getDeclaredFields()) {
        Class<?> t = f.getType();
        boolean ok = !t.isPrimitive()
            || t == boolean.class || t == char.class || t == int.class || t == long.class;
        if (!ok) throw new IllegalArgumentException(
            "Field " + f.getName() + " uses unsupported primitive " + t + " in multipart form; use wrapper or String");
    }
}

Type guard

static boolean supportedPrimitive(Class<?> t) {
    return !t.isPrimitive() || t == boolean.class || t == char.class
        || t == int.class || t == long.class;
}

Prevention

When it happens

Trigger: A @MultipartForm bean containing a field of an unsupported primitive type (e.g. float/double/short/byte depending on supported set) sent via a REST client multipart request.

Common situations: DTO reuse across endpoints where multipart path doesn't handle every primitive; adding a new primitive field like `float weight` to an upload form bean.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/ec03582896e568af. Report an issue: GitHub.