{"record":{"id":"7f168510008ecb97","repo":"apache/dolphinscheduler","slug":"20016-7f1685","errorCode":"20016","errorMessage":"resource not exist or no permission,please view the task node and remove error resource","messagePattern":"resource not exist or no permission,please view the task node and remove error resource","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java","lineNumber":375,"sourceCode":"                taskDefinition.setFlag(Flag.NO);\n                taskDefinitionLog.setFlag(Flag.NO);\n                break;\n            case ONLINE:\n                taskDatasourcePermissionChecker.checkPermission(loginUser,\n                        Collections.singletonList(taskDefinitionLog));\n                taskSubWorkflowPermissionChecker.checkPermission(loginUser,\n                        Collections.singletonList(taskDefinitionLog));\n                String resourceIds = taskDefinition.getResourceIds();\n                if (StringUtils.isNotBlank(resourceIds)) {\n                    Integer[] resourceIdArray =\n                            Arrays.stream(resourceIds.split(\",\")).map(Integer::parseInt).toArray(Integer[]::new);\n                    PermissionCheck<Integer> permissionCheck = new PermissionCheck(AuthorizationType.RESOURCE_FILE_ID,\n                            processService, resourceIdArray, loginUser.getId(), log);\n                    try {\n                        permissionCheck.checkPermission();\n                    } catch (Exception e) {\n                        log.error(\"Resources permission check error, resourceIds:{}.\", resourceIds, e);\n                        throw new ServiceException(Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION);\n                    }\n                }\n                taskDefinition.setFlag(Flag.YES);\n                taskDefinitionLog.setFlag(Flag.YES);\n                break;\n            default:\n                log.warn(\"Parameter releaseState is invalid.\");\n                throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, Constants.RELEASE_STATE);\n        }\n        boolean updateSuccess = taskDefinitionDao.updateById(taskDefinition);\n        int updateLog = taskDefinitionLogMapper.updateById(taskDefinitionLog);\n        if (updateSuccess != (updateLog == 1)) {\n            log.error(\"Update taskDefinition state or taskDefinitionLog state error, taskDefinitionCode:{}.\", code);\n            throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);\n        }\n        log.info(\"Update taskDefinition state or taskDefinitionLog state to complete, taskDefinitionCode:{}.\",\n                code);\n    }","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java#L357-L393","documentation":"ServiceException(Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION, 20016) is thrown when the resource file IDs attached to the task definition fail the PermissionCheck (AuthorizationType.RESOURCE_FILE_ID) during an ONLINE release. Either a referenced resource no longer exists or the releasing user lacks permission on it.","triggerScenarios":"releaseTaskDefinition with releaseState=ONLINE where the task definition's resourceIds reference resource files that were deleted, moved, or are not owned/authorized for loginUser.getId().","commonSituations":"An admin deleted a shared resource file that workflow tasks still reference; user account changed (different tenant/permissions) since the task was authored; environment migration left resource IDs dangling.","solutions":["Open the task definition and remove/replace the stale resource references in the task node","Re-upload the missing resource file and re-link it, ensuring the current user has access","Grant loginUser permission on the referenced resource files, then retry the release","Audit all task definitions for dangling resourceIds after resource cleanup"],"exampleFix":"// before: releasing with stale resourceIds\nresourceIds: \"10001,10002\" // 10002 deleted\n// after: remove the deleted id (or re-add the resource) before releasing\nresourceIds: \"10001\"","handlingStrategy":"validation","validationCode":"List<Integer> ids = Arrays.stream(resourceIds.split(\",\")).map(Integer::parseInt).collect(toList());\nList<Resource> owned = resourceService.authorizedResourceFiles(loginUser.getId());\nList<Integer> missing = ids.stream().filter(id -> owned.stream().noneMatch(r -> r.getId().equals(id))).collect(toList());\nif (!missing.isEmpty()) throw new IllegalStateException(\"missing/unauthorized resources: \" + missing);","typeGuard":"boolean allResourcesAuthorized(User user, List<Integer> resourceIds) {\n    return resourceService.authorizedResourceFiles(user.getId()).stream()\n        .map(Resource::getId).collect(toSet()).containsAll(resourceIds);\n}","tryCatchPattern":"try {\n    service.releaseTaskDefinition(loginUser, projectCode, code, ReleaseState.ONLINE);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION.getCode()) { /* edit task node to drop stale resources */ }\n    throw e;\n}","preventionTips":["Before deleting a resource file, search tasks referencing its id","Re-check resource permissions whenever users/tenants change","After environment migrations, validate all resourceIds resolve","Run PermissionCheck-equivalent pre-validation before releasing workflows"],"tags":["resource","permission","task-definition","dolphinscheduler"],"backgroundTag":"resource-not-exist-or-no-permission","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"}