{"record":{"id":"b1371c611aca75b8","repo":"apache/dolphinscheduler","slug":"the-file-content-is-null","errorCode":null,"errorMessage":"The file content is null","messagePattern":"The file content 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":76,"sourceCode":"            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)) {\n            throw new ServiceException(\"Thr resource is not exists: \" + resourceAbsolutePath);\n        }\n    }\n\n    public void exceptionResourceExists(String resourceAbsolutePath) {\n        if (storageOperator.exists(resourceAbsolutePath)) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/AbstractResourceValidator.java#L58-L94","documentation":"exceptionFileContentInvalidated rejects an empty or null file content string with ServiceException(\"The file content is null\"). Used by endpoints that create or update text resources (e.g. online file editor save) where the request body must include the content to write.","triggerScenarios":"Saving/creating a text resource (createOrUpdate online content API) with content=null or an empty string in the request payload.","commonSituations":"Frontend editor sends empty body when the buffer was never loaded; API scripts forget the content field; a failed read upstream produced an empty string passed through.","solutions":["Include a non-empty 'content' field in the request body when saving a text resource.","If saving an intentionally empty file, first check the endpoint's expectations or use the file-upload path with a placeholder byte.","Guard in client code: reject empty content before calling the save API."],"exampleFix":"// before\n{\"resource_name\":\"script.sql\", \"content\":\"\"}\n// after\n{\"resource_name\":\"script.sql\", \"content\":\"SELECT 1;\"}","handlingStrategy":"validation","validationCode":"// client-side pre-check\nif (content == null || content.isEmpty()) {\n    throw new IllegalArgumentException(\"content must be a non-empty string when saving a text resource\");\n}","typeGuard":"function hasContent(p) {\n  return typeof p.content === 'string' && p.content.length > 0;\n}","tryCatchPattern":"try {\n    // save text resource\n} catch (ServiceException e) {\n    if (e.getMessage().contains(\"The file content is null\")) {\n        // prompt the user for content or abort the save\n    } else throw e;\n}","preventionTips":["Require the content field in request DTOs with @NotBlank","Disable the editor 'save' button while the buffer is empty","Never propagate empty strings from failed reads into save calls"],"tags":["resource","validation","empty-content"],"backgroundTag":"empty-required-field","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"}