apache/dolphinscheduler · error · ServiceException

RESOURCE_NOT_EXIST

RESOURCE_NOT_EXIST

Error message

Status.RESOURCE_NOT_EXIST

What it means

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).

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java:287

        }
    }

    @Override
    public void checkConnection(DbType type, ConnectionParam connectionParam) {
        DataSourceProcessor sshDataSourceProcessor = DataSourceUtils.getDatasourceProcessor(type);
        boolean connectivity = sshDataSourceProcessor.checkDataSourceConnectivity(connectionParam);
        if (connectivity) {
            return;
        }
        throw new ServiceException(Status.CONNECTION_TEST_FAILURE);
    }

    @Override
    public void connectionTest(User loginUser, int id) {
        DataSource dataSource = dataSourceDao.queryById(id);

        if (dataSource == null) {
            throw new ServiceException(Status.RESOURCE_NOT_EXIST);
        }

        if (!canOperatorPermissions(loginUser, new Object[]{id}, AuthorizationType.DATASOURCE,
                ApiFuncIdentificationConstant.DATASOURCE)) {
            throw new ServiceException(Status.USER_NO_OPERATION_PERM);
        }

        checkConnection(dataSource.getType(),
                DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams()));
    }

    @Override
    @Transactional
    public void delete(User loginUser, int datasourceId) {
        // query datasource by id
        DataSource dataSource = dataSourceDao.queryById(datasourceId);

        if (dataSource == null) {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Refresh the data source list and use a valid id
  2. Verify the id via GET /datasources/list before testing
  3. Recreate the data source if it was deleted and re-run the connection test
  4. Confirm you are operating against the intended environment/database

Example fix

// before
connectionTest(user, deletedId); // throws
// after
DataSource ds = dataSourceDao.queryById(id);
if (ds != null) {
    connectionTest(user, id);
}
Defensive patterns

Strategy: validation

Validate before calling

if (dataSourceService.queryDataSourceList(loginUser).stream().noneMatch(ds -> ds.getId() == id)) {
    throw new IllegalArgumentException("datasource " + id + " not found");
}

Try / catch

try { service.connectionTest(user, id); } catch (ServiceException e) { if (e.getCode() == 20004) { refreshDatasourceList(); } else throw e; }

Prevention

When it happens

Trigger: POST /datasources/{id}/connect with a non-existent or already-deleted data source id.

Common situations: UI re-testing a data source deleted in another tab; stale cached id after environment switch; automated health-check scripts holding old ids.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/b3205026970e3f21. Report an issue: GitHub.