{"record":{"id":"b3205026970e3f21","repo":"apache/dolphinscheduler","slug":"resource-not-exist","errorCode":"RESOURCE_NOT_EXIST","errorMessage":"Status.RESOURCE_NOT_EXIST","messagePattern":"Status\\.RESOURCE_NOT_EXIST","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java","lineNumber":287,"sourceCode":"        }\n    }\n\n    @Override\n    public void checkConnection(DbType type, ConnectionParam connectionParam) {\n        DataSourceProcessor sshDataSourceProcessor = DataSourceUtils.getDatasourceProcessor(type);\n        boolean connectivity = sshDataSourceProcessor.checkDataSourceConnectivity(connectionParam);\n        if (connectivity) {\n            return;\n        }\n        throw new ServiceException(Status.CONNECTION_TEST_FAILURE);\n    }\n\n    @Override\n    public void connectionTest(User loginUser, int id) {\n        DataSource dataSource = dataSourceDao.queryById(id);\n\n        if (dataSource == null) {\n            throw new ServiceException(Status.RESOURCE_NOT_EXIST);\n        }\n\n        if (!canOperatorPermissions(loginUser, new Object[]{id}, AuthorizationType.DATASOURCE,\n                ApiFuncIdentificationConstant.DATASOURCE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        checkConnection(dataSource.getType(),\n                DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams()));\n    }\n\n    @Override\n    @Transactional\n    public void delete(User loginUser, int datasourceId) {\n        // query datasource by id\n        DataSource dataSource = dataSourceDao.queryById(datasourceId);\n\n        if (dataSource == null) {","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java#L269-L305","documentation":"Raised in DataSourceServiceImpl.connectionTest when dataSourceDao.queryById(id) returns null: the datasource id supplied by the caller does not correspond to any stored datasource (it may have been deleted or the id is wrong).","triggerScenarios":"POST /datasources/{id}/connect with a non-existent or already-deleted data source id.","commonSituations":"UI re-testing a data source deleted in another tab; stale cached id after environment switch; automated health-check scripts holding old ids.","solutions":["Refresh the data source list and use a valid id","Verify the id via GET /datasources/list before testing","Recreate the data source if it was deleted and re-run the connection test","Confirm you are operating against the intended environment/database"],"exampleFix":"// before\nconnectionTest(user, deletedId); // throws\n// after\nDataSource ds = dataSourceDao.queryById(id);\nif (ds != null) {\n    connectionTest(user, id);\n}","handlingStrategy":"validation","validationCode":"if (dataSourceService.queryDataSourceList(loginUser).stream().noneMatch(ds -> ds.getId() == id)) {\n    throw new IllegalArgumentException(\"datasource \" + id + \" not found\");\n}","typeGuard":null,"tryCatchPattern":"try { service.connectionTest(user, id); } catch (ServiceException e) { if (e.getCode() == 20004) { refreshDatasourceList(); } else throw e; }","preventionTips":["Fetch fresh ids before testing","Handle deletes across sessions/tabs gracefully","Confirm target environment"],"tags":["datasource","not-found","rest"],"backgroundTag":"resource-not-found","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"}