{"record":{"id":"672a14f114be8896","repo":"quarkusio/quarkus","slug":"error-decoding-content-transfer-encoding-attribute","errorCode":null,"errorMessage":"Error decoding content-transfer-encoding attribute (wrapped NullPointerException/IllegalArgumentException)","messagePattern":"Error decoding content-transfer-encoding attribute \\(wrapped NullPointerException/IllegalArgumentException\\)","errorType":"exception","errorClass":"ErrorDataDecoderException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDecoder.java","lineNumber":751,"sourceCode":"                    // read next values and store them in the map as Attribute\n                    for (int i = 2; i < contents.length; i++) {\n                        String[] values = contents[i].split(\"=\", 2);\n                        Attribute attribute;\n                        try {\n                            attribute = getContentDispositionAttribute(values);\n                        } catch (NullPointerException | IllegalArgumentException e) {\n                            throw new ErrorDataDecoderException(e);\n                        }\n                        currentFieldAttributes.put(attribute.getName(), attribute);\n                    }\n                }\n            } else if (HttpHeaderNames.CONTENT_TRANSFER_ENCODING.contentEqualsIgnoreCase(contents[0])) {\n                Attribute attribute;\n                try {\n                    attribute = factory.createAttribute(response, HttpHeaderNames.CONTENT_TRANSFER_ENCODING.toString(),\n                            cleanString(contents[1]));\n                } catch (NullPointerException | IllegalArgumentException e) {\n                    throw new ErrorDataDecoderException(e);\n                }\n\n                currentFieldAttributes.put(HttpHeaderNames.CONTENT_TRANSFER_ENCODING, attribute);\n            } else if (HttpHeaderNames.CONTENT_LENGTH.contentEqualsIgnoreCase(contents[0])) {\n                Attribute attribute;\n                try {\n                    attribute = factory.createAttribute(response, HttpHeaderNames.CONTENT_LENGTH.toString(),\n                            cleanString(contents[1]));\n                } catch (NullPointerException | IllegalArgumentException e) {\n                    throw new ErrorDataDecoderException(e);\n                }\n\n                currentFieldAttributes.put(HttpHeaderNames.CONTENT_LENGTH, attribute);\n            } else if (HttpHeaderNames.CONTENT_TYPE.contentEqualsIgnoreCase(contents[0])) {\n                // Take care of possible \"multipart/mixed\"\n                if (HttpHeaderValues.MULTIPART_MIXED.contentEqualsIgnoreCase(contents[1])) {\n                    if (currentStatus == MultiPartStatus.DISPOSITION) {\n                        String values = StringUtil.substringAfter(contents[2], '=');","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDecoder.java#L733-L769","documentation":"This ErrorDataDecoderException wraps a NullPointerException or IllegalArgumentException thrown while creating the content-transfer-encoding attribute during multipart response parsing. The HttpPostStandardBodyDataFactory (attribute factory) rejected the attribute name or the cleaned header value, so the decoder aborts the whole multipart decode. It indicates a malformed Content-Transfer-Encoding disposition parameter in the multipart response body.","triggerScenarios":"The multipart response contains a Content-Transfer-Encoding disposition attribute whose value, after cleanString(), is null or otherwise rejected by factory.createAttribute() (e.g. missing value after '=', empty token, or illegal characters).","commonSituations":"Non-Quarkus/Netty-incompatible servers or proxies emitting hand-crafted multipart bodies; server frameworks producing 'Content-Transfer-Encoding:' with no value; custom response transformations that mangle disposition headers.","solutions":["Inspect the raw multipart response body (enable wire logging) and fix the malformed Content-Transfer-Encoding parameter on the server.","Check the value after 'Content-Transfer-Encoding=' is non-empty and contains no control characters or stray quotes.","If the server cannot be fixed, sanitize/normalize the response before decoding or use a custom AttributeFactory tolerant of the value.","Compare with a working client (e.g. curl) to confirm the header difference and report/fix the server-side multipart writer."],"exampleFix":"// before (malformed server output)\nContent-Disposition: form-data; name=\"file\"; Content-Transfer-Encoding=\n// after (well-formed)\nContent-Disposition: form-data; name=\"file\"; Content-Transfer-Encoding=\"binary\"","handlingStrategy":"validation","validationCode":"// Validate the disposition parameter before the server sends it (server-side check)\nString cte = params.get(\"Content-Transfer-Encoding\");\nif (cte == null || cte.isBlank()) {\n    throw new IllegalStateException(\"Content-Transfer-Encoding must have a non-empty value\");\n}","typeGuard":"static boolean isValidDispositionValue(String v) {\n    return v != null && !v.isBlank() && v.chars().allMatch(c -> c >= 0x20 && c != 0x7f);\n}","tryCatchPattern":"try {\n    List<HttpResponsePart> parts = decoder.decode(...);\n} catch (ErrorDataDecoderException e) {\n    log.warn(\"Malformed multipart disposition (Content-Transfer-Encoding): {}\", e.getMessage(), e);\n    throw new BadRequestException(\"Malformed multipart response\", e);\n}","preventionTips":["Always emit quoted, non-empty values for disposition parameters.","Wire-log responses during integration to catch malformed part headers early.","Test against real server output, not hand-written multipart samples.","Keep server multipart serializer libraries up to date."],"tags":["multipart","http-client","decoding","resteasy-reactive"],"backgroundTag":"multipart-decode-failed","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"}