OtterMind/Chat2DB · warning · CliDomainException
invalid_datasource_create_args
invalid_datasource_create_args
Error message
datasource-create requires dbType
What it means
CliDomainException code invalid_datasource_create_args from validateCreateRequest: dbType must be non-blank to create a datasource. dbType is required first because subsequent normalization and driver defaults depend on it.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/cli/CliDataSourceServiceImpl.java:201
}
}
private void normalizeConnectionTestRequest(CliConnectionTestRequest request) {
request.setDbType(canonicalDbType(request.getDbType()));
}
private DbDataSourcePreConnectRequest buildPreConnectParam(CliConnectionTestRequest source) {
if (source.getDataSourceId() != null) {
return existingDatasourcePreConnectParam(source.getDataSourceId());
}
String url = JdbcUrlUtils.resetUrl(connectionTestUrl(source), source.getDbType(), source.getServiceType());
return cliDataSourceConverter.connectionTest2param(source, url, defaultSsh(source.getSsh()),
defaultDriverConfig(source.getDriverConfig(), source.getDbType()));
}
private void validateCreateRequest(CliDataSourceCreateRequest request) {
if (StringUtils.isBlank(request.getDbType())) {
throw new CliDomainException("invalid_datasource_create_args", "datasource-create requires dbType");
}
if (request.getEnvironmentId() == null) {
throw new CliDomainException("invalid_datasource_create_args", "datasource-create requires environmentId");
}
if (request.getPassword() == null) {
throw new CliDomainException("invalid_datasource_create_args", "datasource-create requires password");
}
boolean hasUrl = StringUtils.isNotBlank(request.getUrl());
boolean hasHostFields = StringUtils.isNotBlank(request.getHost())
|| StringUtils.isNotBlank(request.getPort())
|| StringUtils.isNotBlank(request.getDatabase());
if (hasUrl && hasHostFields) {
throw new CliDomainException("invalid_datasource_create_args",
"url cannot be combined with host, port, or database");
}
if (!hasUrl && !(StringUtils.isNotBlank(request.getHost())
&& StringUtils.isNotBlank(request.getPort())
&& StringUtils.isNotBlank(request.getDatabase()))) {View on GitHub (pinned to 5ee1e990e7)
Solutions
- Set dbType to a supported value (e.g. MYSQL, POSTGRESQL, ORACLE) in the create request.
- Validate the request payload shape before sending; dbType is mandatory.
Example fix
// before
create({ host, port, database, user, password, environmentId })
// after
create({ dbType: 'POSTGRESQL', host, port, database, user, password, environmentId }) Defensive patterns
Strategy: validation
Validate before calling
if (StringUtils.isBlank(request.getDbType())) {
throw new IllegalArgumentException("dbType is required to create a datasource");
} Type guard
public boolean hasDbType(CliDataSourceCreateRequest r) {
return r != null && StringUtils.isNotBlank(r.getDbType());
} Try / catch
try {
cliDataSourceService.create(request);
} catch (CliDomainException e) {
if ("invalid_datasource_create_args".equals(e.getCode())) {
return badRequest(e.getMessage());
}
throw e;
} Prevention
- Make dbType a required field in the request DTO/UI form.
- Validate the create payload schema before sending.
When it happens
Trigger: POST datasource create without a dbType field (or blank), while other fields may be present.
Common situations: UI/automation that leaves dbType unset or sends an empty string; a malformed payload that dropped the type.
Related errors
- datasource_not_found
- invalid_connection_test_args
- No database connection context found. Call list_all_datasour
- No database connection context found. Provide dataSourceId/d
- datasource_connection_failed
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/ec1d32163dc8a6e5.
Report an issue: GitHub.