{"record":{"id":"44cc1837b26e762a","repo":"apache/dolphinscheduler","slug":"update-the-resource-file-from-content-fileabsolu","errorCode":null,"errorMessage":"Update the resource file from content: {fileAbsolutePath} failed","messagePattern":"Update the resource file from content: (.+?) failed","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java","lineNumber":352,"sourceCode":"                .build();\n    }\n\n    @Override\n    public void updateFileFromContent(UpdateFileFromContentRequest updateFileContentRequest) {\n        UpdateFileFromContentDto updateFileFromContentDto =\n                updateFileFromContentRequestTransformer.transform(updateFileContentRequest);\n        updateFileFromContentDtoValidator.validate(updateFileFromContentDto);\n\n        String srcLocalTmpFileAbsolutePath = copyFileToLocal(updateFileFromContentDto.getFileContent());\n        try {\n            storageOperator.upload(srcLocalTmpFileAbsolutePath, updateFileFromContentDto.getFileAbsolutePath(), true,\n                    true);\n            ApiServerMetrics.recordApiResourceUploadSize(updateFileFromContentDto.getFileContent().length());\n            log.info(\"Success upload resource file: {} complete.\", updateFileFromContentDto.getFileAbsolutePath());\n        } catch (Exception ex) {\n            // If exception, clear the tmp path\n            FileUtils.deleteFile(srcLocalTmpFileAbsolutePath);\n            throw new ServiceException(\"Update the resource file from content: \"\n                    + updateFileFromContentDto.getFileAbsolutePath() + \" failed\", ex);\n        }\n    }\n\n    @Override\n    public void downloadResource(HttpServletResponse response, DownloadFileRequest downloadFileRequest) {\n        DownloadFileDto downloadFileDto = DownloadFileDto.builder()\n                .loginUser(downloadFileRequest.getLoginUser())\n                .fileAbsolutePath(downloadFileRequest.getFileAbsolutePath())\n                .build();\n        downloadFileDtoValidator.validate(downloadFileDto);\n\n        String fileName = new File(downloadFileDto.getFileAbsolutePath()).getName();\n        String localTmpFileAbsolutePath = FileUtils.getDownloadFilename(fileName);\n\n        try {\n            storageOperator.download(downloadFileRequest.getFileAbsolutePath(), localTmpFileAbsolutePath, true);\n            int length = (int) new File(localTmpFileAbsolutePath).length();","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java#L334-L370","documentation":"ResourcesServiceImpl.updateFileFromContent wraps any exception thrown while persisting an updated resource file into ServiceException(\"Update the resource file from content: <path> failed\", ex). The flow writes the new content to a local tmp file, uploads it to storage, and records metrics; a failure at any point (IO error, storage failure, closure leak) triggers this wrapped error. The tmp file is cleaned up before rethrowing.","triggerScenarios":"Editing/saving a resource file via the UI/API when the storage backend (HDFS/S3/OSS) is unreachable; local disk full or permission denied writing srcLocalTmpFileAbsolutePath; underlying StorageOperate.updateResource throws any exception.","commonSituations":"S3/HDFS credentials expired; resource center storage misconfigured after upgrade; disk quota exceeded on the API server node; oversized file content failing upload.","solutions":["Inspect the wrapped cause (ex) in the server log — the root exception identifies whether it's storage, IO, or configuration.","Verify storage configuration (resource.storage.type and related credentials/endpoints) and connectivity from the API server.","Check API server disk space and write permissions for the tmp directory, then retry the file update."],"exampleFix":"// before: ignoring cause detail\n// ServiceException(\"Update the resource file from content: /x.sql failed\", ex)\n\n// after: check logs for root cause and fix storage\n// e.g. storage.type=s3 with expired credentials -> refresh access-key/secret-key in common.properties, retry","handlingStrategy":"try-catch","validationCode":"// pre-checks: disk space and storage connectivity\nlong usable = new File(tmpDir).getUsableSpace();\nif (usable < content.length() * 2L) { throw new IllegalStateException(\"Insufficient disk for tmp resource write\"); }","typeGuard":null,"tryCatchPattern":"try {\n    resourcesService.updateFileFromContent(dto);\n} catch (ServiceException e) {\n    // inspect e.getCause() for storage vs IO root cause; log and alert\n}","preventionTips":["Monitor API server disk usage on tmp volumes","Validate storage credentials/endpoints before file operations","Alert on the wrapped cause exceptions in logs"],"tags":["resources","storage","io"],"backgroundTag":"file-write-failed","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"}