{"record":{"id":"f33d487f5495524b","repo":"OtterMind/Chat2DB","slug":"common-datanotfound","errorCode":"common.dataNotFound","errorMessage":"common.dataNotFound","messagePattern":"common\\.dataNotFound","errorType":"exception","errorClass":"DataNotFoundException","httpStatus":null,"severity":"warning","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/task/TaskRecordServiceImpl.java","lineNumber":72,"sourceCode":"        if (!taskSchedulerService.cancel(id)) {\n            Task task = getTask(id);\n            if (task == null || StringUtils.equalsAnyIgnoreCase(\n                    task.getTaskStatus(), \"FINISHED\", STATUS_STOP, \"ERROR\")) {\n                return;\n            }\n        }\n        TaskRecordUpdateRequest request = new TaskRecordUpdateRequest();\n        request.setId(id);\n        request.setTaskStatus(STATUS_STOP);\n        request.setDownloadUrl(\"\");\n        updateTask(request);\n    }\n\n    @Override\n    public TaskDownload resolveDownload(Long id, Long userId) {\n        Task task = getTask(id);\n        if (task == null || StringUtils.isBlank(task.getDownloadUrl())) {\n            throw new DataNotFoundException();\n        }\n        if (!Objects.equals(userId, task.getUserId())) {\n            throw new PermissionDeniedBusinessException();\n        }\n\n        File file = new File(task.getDownloadUrl());\n        if (!file.exists() || !file.canRead()) {\n            throw new DataNotFoundException();\n        }\n        return TaskDownload.builder()\n                .fileName(file.getName())\n                .fileUri(file.toURI().toString())\n                .build();\n    }\n}\n","sourceCodeStart":54,"sourceCodeEnd":88,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/task/TaskRecordServiceImpl.java#L54-L88","documentation":"DataNotFoundException ('common.dataNotFound') from TaskRecordServiceImpl.resolveDownload when the task lookup returns null or the task's downloadUrl is blank — there is nothing to download.","triggerScenarios":"GET/resolve a task download by an id whose task does not exist, was never assigned a downloadUrl (export not finished / failed), or whose URL field was cleared (e.g. after STATUS_STOP reset).","commonSituations":"Polling a download URL before the export task has finished; task id mistyped; task cancelled (stopTask blanks the URL); export failed without producing a file.","solutions":["Confirm the task id exists and that the export has reached a completed status before resolving the download.","If the task was stopped, re-trigger the export to regenerate downloadUrl.","Validate id is non-null and present in task list before calling resolveDownload."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Task t = getTask(id);\nif (t == null || StringUtils.isBlank(t.getDownloadUrl())) throw new DataNotFoundException();","typeGuard":"boolean isDownloadReady(Task t) { return t != null && StringUtils.isNotBlank(t.getDownloadUrl()); }","tryCatchPattern":null,"preventionTips":["Only resolve a download after the export task reaches a completed status.","Re-trigger export if the task was stopped (stopTask blanks downloadUrl).","Validate id presence in the task list first."],"tags":["task","download","export","not-found"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}