{"record":{"id":"b61dfe11adf4f6b5","repo":"quarkusio/quarkus","slug":"different-array-length","errorCode":null,"errorMessage":"Different array length","messagePattern":"Different array length","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/PausableHttpPostRequestEncoder.java","lineNumber":493,"sourceCode":"     * Add a series of Files associated with one File parameter\n     *\n     * @param name\n     *        the name of the parameter\n     * @param file\n     *        the array of files\n     * @param contentType\n     *        the array of content Types associated with each file\n     * @param isText\n     *        the array of isText attribute (False meaning binary mode) for each file\n     * @throws IllegalArgumentException\n     *         also throws if array have different sizes\n     * @throws ErrorDataEncoderException\n     *         if the encoding is in error or if the finalize were already done\n     */\n    public void addBodyFileUploads(String name, File[] file, String[] contentType, boolean[] isText)\n            throws ErrorDataEncoderException {\n        if (file.length != contentType.length && file.length != isText.length) {\n            throw new IllegalArgumentException(\"Different array length\");\n        }\n        for (int i = 0; i < file.length; i++) {\n            addBodyFileUpload(name, file[i], contentType[i], isText[i]);\n        }\n    }\n\n    /**\n     * Add the InterfaceHttpData to the Body list\n     *\n     * @throws NullPointerException\n     *         for data\n     * @throws ErrorDataEncoderException\n     *         if the encoding is in error or if the finalize were already done\n     */\n    public void addBodyHttpData(InterfaceHttpData data) throws ErrorDataEncoderException {\n        if (headerFinalized) {\n            throw new ErrorDataEncoderException(\"Cannot add value once finalized\");\n        }","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/PausableHttpPostRequestEncoder.java#L475-L511","documentation":"IllegalArgumentException from PausableHttpPostRequestEncoder.addBodyFileUploads: the parallel arrays passed for a multi-file upload parameter (files, contentTypes, isText) have different lengths. Each file needs exactly one content type and one isText flag; the array length mismatch is the fault.","triggerScenarios":"Calling addBodyFileUploads with arrays of mismatched lengths, e.g. file.length=2 but contentType.length=1.","commonSituations":"Building parallel arrays programmatically and skipping an entry for a file with unknown content type; refactoring single-upload code to batch mode.","solutions":["Pad missing content types with a sensible default (e.g. application/octet-stream) before the call","Assert array lengths are equal before calling addBodyFileUploads","Switch to calling addBodyFileUpload per file to avoid parallel-array pitfalls"],"exampleFix":"// before\nencoder.addBodyFileUploads(\"files\", files, contentTypes, isTextFlags);\n// after\nif (files.length != contentTypes.length || files.length != isTextFlags.length) {\n    throw new IllegalStateException(\"arrays must match\");\n}\nencoder.addBodyFileUploads(\"files\", files, contentTypes, isTextFlags);","handlingStrategy":"validation","validationCode":"if (file.length != contentType.length || file.length != isText.length) { throw new IllegalArgumentException(\"arrays must have equal length\"); }","typeGuard":"null","tryCatchPattern":"try { encoder.addBodyFileUploads(name, files, types, flags); } catch (IllegalArgumentException e) { /* fix arrays or add one-by-one */ }","preventionTips":["Prefer a small record/DTO list over parallel arrays","Default missing content types to application/octet-stream","Validate array lengths in a helper before batch uploads"],"tags":["multipart","illegal-argument","array-length","resteasy-reactive"],"backgroundTag":"argument-length-mismatch","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"}