{"record":{"id":"0544166f1ed0a6de","repo":"apache/dolphinscheduler","slug":"the-file-is-null","errorCode":null,"errorMessage":"The file is null","messagePattern":"The file is null","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java","lineNumber":70,"sourceCode":"        this.storageOperator = storageOperator;\n        this.tenantDao = tenantDao;\n    }\n\n    public void exceptionResourceAbsolutePathInvalidated(String resourceAbsolutePath) {\n        if (StringUtils.isBlank(resourceAbsolutePath)) {\n            throw new ServiceException(\"The resource path is null\");\n        }\n        if (!resourceAbsolutePath.startsWith(storageOperator.getStorageBaseDirectory())) {\n            throw new ServiceException(\"Invalidated resource path: \" + resourceAbsolutePath);\n        }\n        if (resourceAbsolutePath.contains(\"..\")) {\n            throw new ServiceException(\"Invalidated resource path: \" + resourceAbsolutePath);\n        }\n    }\n\n    public void exceptionFileInvalidated(MultipartFile file) {\n        if (file == null) {\n            throw new ServiceException(\"The file is null\");\n        }\n    }\n\n    public void exceptionFileContentInvalidated(String fileContent) {\n        if (StringUtils.isEmpty(fileContent)) {\n            throw new ServiceException(\"The file content is null\");\n        }\n    }\n\n    public void exceptionFileContentCannotFetch(String fileAbsolutePath) {\n        String fileExtension = Files.getFileExtension(fileAbsolutePath);\n        if (!FILE_SUFFIXES_WHICH_CAN_FETCH_CONTENT.contains(fileExtension)) {\n            throw new ServiceException(\"The file type: \" + fileExtension + \" cannot be fetched\");\n        }\n    }\n\n    public void exceptionResourceNotExists(String resourceAbsolutePath) {\n        if (!storageOperator.exists(resourceAbsolutePath)) {","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java#L52-L88","documentation":"exceptionFileInvalidated rejects a null MultipartFile with ServiceException(\"The file is null\"). It is called by resource upload/create endpoints to ensure a file attachment was actually provided before storage operations are attempted.","triggerScenarios":"POSTing to resource upload endpoints without a multipart file part, or with a part whose name does not match what the controller binds (so the MultipartFile binds as null).","commonSituations":"curl/script uploads missing -F file=@... or using the wrong form-field name; frontend forms not setting enctype=multipart/form-data; request size filter silently dropping the file part.","solutions":["Attach the file under the form field name the endpoint expects (typically 'file').","Ensure the request Content-Type is multipart/form-data and the client includes the file part.","Check multipart max-file-size/max-request-size settings if the part is being dropped server-side."],"exampleFix":"// before\ncurl -X POST .../resources -H 'token: ...'      # no file part\n// after\ncurl -X POST .../resources -H 'token: ...' -F 'file=@script.sql' -F 'type=FILE'","handlingStrategy":"validation","validationCode":"// client-side pre-check (browser FormData)\nif (!formData.has('file') || !formData.get('file').name) {\n    throw new Error(\"A file must be attached under the 'file' form field\");\n}","typeGuard":"function hasFilePart(req) {\n  return req.file != null && typeof req.file.originalname === 'string' && req.file.size > 0;\n}","tryCatchPattern":"try {\n    // upload resource\n} catch (ServiceException e) {\n    if (e.getMessage().equals(\"The file is null\")) {\n        // fix the multipart request and retry\n    } else throw e;\n}","preventionTips":["Use -F 'file=@path' with curl and the exact expected form-field name","Set enctype=\"multipart/form-data\" on upload forms","Verify servlet multipart limits (max-file-size) are not silently dropping the part"],"tags":["resource","upload","null-parameter","multipart"],"backgroundTag":"missing-required-argument","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}