{"record":{"id":"5886d871dabc5a99","repo":"halo-dev/halo","slug":"invalid-parameter-of-file","errorCode":null,"errorMessage":"Invalid parameter of file","messagePattern":"Invalid parameter of file","errorType":"validation","errorClass":"ServerWebInputException","httpStatus":400,"severity":"error","filePath":"application/src/main/java/run/halo/app/core/endpoint/console/PluginEndpoint.java","lineNumber":659,"sourceCode":"    /** Multipart payload for installing a plugin. */\n    @Schema(name = \"PluginInstallRequest\", types = \"object\")\n    public static class InstallRequest {\n\n        private final MultiValueMap<String, Part> multipartData;\n\n        public InstallRequest(MultiValueMap<String, Part> multipartData) {\n            this.multipartData = multipartData;\n        }\n\n        /** Plugin JAR file. */\n        @Schema(requiredMode = NOT_REQUIRED)\n        public FilePart getFile() {\n            var part = multipartData.getFirst(\"file\");\n            if (part == null) {\n                throw new ServerWebInputException(\"Form field file is required\");\n            }\n            if (!(part instanceof FilePart file)) {\n                throw new ServerWebInputException(\"Invalid parameter of file\");\n            }\n            if (!Paths.get(file.filename()).toString().endsWith(\".jar\")) {\n                throw new ServerWebInputException(\"Invalid file type, only jar is supported\");\n            }\n            return file;\n        }\n\n        /** Plugin preset name. Halo finds the plugin from plugin presets. */\n        @Schema(requiredMode = NOT_REQUIRED)\n        public Mono<String> getPresetName() {\n            var part = multipartData.getFirst(\"presetName\");\n            if (part == null) {\n                return Mono.error(new ServerWebInputException(\"Form field presetName is required.\"));\n            }\n            if (!(part instanceof FormFieldPart presetName)) {\n                return Mono.error(new ServerWebInputException(\"Invalid format of presetName field, string required\"));\n            }\n            if (!StringUtils.hasText(presetName.value())) {","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/core/endpoint/console/PluginEndpoint.java#L641-L677","documentation":"InstallRequest.getFile() throws ServerWebInputException (HTTP 400) 'Invalid parameter of file' when a \"file\" part exists but is not a FilePart (e.g. it is a FormFieldPart). The installer needs an actual file part to read the JAR bytes, and additionally requires the filename to end in .jar (checked next).","triggerScenarios":"Multipart install request where the \"file\" field is sent as a plain text form field rather than a file upload; or where a proxy converts the file part into a form field. Also reachable if the part type is unexpected due to a malformed multipart body.","commonSituations":"Client sends file as a string field by mistake; using the wrong content-type for the part; a tool that flattens file uploads into form fields; test harness posting a form field named file.","solutions":["Send the plugin JAR as a real file part (multipart file upload) under the \"file\" field.","Ensure the field is a binary file upload, not a text form field.","Verify the filename ends in .jar to avoid the follow-on 'Invalid file type' error."],"exampleFix":"// before (file sent as text field)\nfd.append('file', '/path/to/plugin.jar')\n\n// after (file sent as binary FilePart)\nfd.append('file', fileInput.files[0]) // File object from <input type=file>","handlingStrategy":"validation","validationCode":"if (!(multipartData.getFirst(\"file\") instanceof FilePart)) {\n    return Mono.error(new ServerWebInputException(\"Invalid parameter of file\"));\n}","typeGuard":"static boolean hasJarFilePart(MultiValueMap<String, Part> fd) {\n    Part p = fd.getFirst(\"file\");\n    return p instanceof FilePart f\n        && f.filename() != null && f.filename().endsWith(\".jar\");\n}","tryCatchPattern":null,"preventionTips":["Upload the JAR as a binary file part, not a text form field.","Use an <input type=\"file\"> and append the File object directly.","Verify the filename ends in .jar before submitting."],"tags":["validation","plugin","install","multipart","http-400"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}