OtterMind/Chat2DB · warning · CliDomainException
invalid_connection_test_args
invalid_connection_test_args
Error message
--data-source-id cannot be combined with temporary connection parameters
What it means
CliDomainException code invalid_connection_test_args from validateConnectionTestRequest: when request.dataSourceId is present AND any temporary connection field (dbType, url, host, port, database, user, password, serviceName, serviceType) is also non-blank. The connection test is intentionally one-mode-only.
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:159
throw new CliDomainException("datasource_not_found", "Datasource not found: " + dataSourceId);
}
return dataSource;
}
private void validateConnectionTestRequest(CliConnectionTestRequest request) {
boolean hasDatasourceId = request.getDataSourceId() != null;
boolean hasTemporaryField = StringUtils.isNotBlank(request.getDbType())
|| StringUtils.isNotBlank(request.getUrl())
|| StringUtils.isNotBlank(request.getHost())
|| StringUtils.isNotBlank(request.getPort())
|| StringUtils.isNotBlank(request.getDatabase())
|| StringUtils.isNotBlank(request.getUser())
|| request.getPassword() != null
|| StringUtils.isNotBlank(request.getServiceName())
|| StringUtils.isNotBlank(request.getServiceType());
if (hasDatasourceId) {
if (hasTemporaryField) {
throw new CliDomainException("invalid_connection_test_args",
"--data-source-id cannot be combined with temporary connection parameters");
}
return;
}
if (StringUtils.isBlank(request.getDbType())
|| StringUtils.isBlank(request.getUser())
|| StringUtils.isBlank(request.getPassword())) {
throw new CliDomainException("invalid_connection_test_args",
"temporary mode requires dbType, user, and 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_connection_test_args",
"url cannot be combined with host, port, or database");
}View on GitHub (pinned to 5ee1e990e7)
Solutions
- To test a saved datasource: pass ONLY dataSourceId.
- To test a temporary connection: omit dataSourceId and provide dbType plus connection fields.
- Audit the CLI/script invocation for accidentally-set default values on temporary fields.
Example fix
# before test --data-source-id 5 --host db.prod --port 3306 # after (test saved datasource only) test --data-source-id 5
Defensive patterns
Strategy: validation
Validate before calling
boolean hasId = request.getDataSourceId() != null;
boolean hasTemp = Stream.of(request.getDbType(), request.getUrl(), request.getHost(),
request.getPort(), request.getDatabase(), request.getUser(), request.getServiceName(), request.getServiceType())
.anyMatch(StringUtils::isNotBlank) || request.getPassword() != null;
if (hasId && hasTemp) {
throw new IllegalArgumentException("Choose either dataSourceId or temporary fields, not both");
} Type guard
public boolean isTemporaryMode(CliConnectionTestRequest r) {
return r != null && r.getDataSourceId() == null;
} Try / catch
try {
cliDataSourceService.testConnection(request);
} catch (CliDomainException e) {
if ("invalid_connection_test_args".equals(e.getCode())) {
return badRequest(e.getMessage());
}
throw e;
} Prevention
- Validate mutual exclusivity of dataSourceId vs. temp fields at the CLI/parser boundary.
- Avoid defaulting temp fields when referencing a saved datasource.
- Document one-mode-per-call clearly in CLI help text.
When it happens
Trigger: Calling connection-test with both a dataSourceId and host/url/user/etc., expecting the temp fields to override the stored datasource.
Common situations: CLI flag mix-up: passing --data-source-id together with --host/--url; an automation script defaulting fields while also referencing a saved datasource.
Related errors
- datasource_not_found
- invalid_datasource_create_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/6b6acf96104f07c8.
Report an issue: GitHub.