OtterMind/Chat2DB · error · BusinessException
dataSource.sqlAnalysisError
dataSource.sqlAnalysisError
Error message
Invalid statements
What it means
Thrown by RedisScriptExecutor.execute as a BusinessException (code: dataSource.sqlAnalysisError) when SqlUtils.parse returns an empty list for the provided script. This means the Redis command script could not be parsed into any valid SQL-like statements. The parse uses Druid's SQL parser with the Redis dbType, and an empty result indicates the script is syntactically unrecognizable.
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-redis/src/main/java/ai/chat2db/plugin/redis/RedisScriptExecutor.java:124
public String getTtl(String key) {
Connection connection = Chat2DBContext.getConnection();
return DefaultSQLExecutor.getInstance().execute(connection, String.format(RedisConstants.COMMAND_TTL_KEY, getRedisValue(key)), resultSet -> {
if (resultSet.next()) {
return resultSet.getString(1);
}
return null;
});
}
public List<ExecuteResponse> execute(SqlExecuteRequest command) {
String type = Chat2DBContext.getConnectInfo().getDbType();
DbType dbType = JdbcUtils.parse2DruidDbType(type);
List<String> sqlList = SqlUtils.parse(command.getScript(), dbType,true);
if (CollectionUtils.isEmpty(sqlList)) {
throw new BusinessException(RedisConstants.ERROR_SQL_ANALYSIS);
}
List<ExecuteResponse> result = new ArrayList<>();
for (String originalSql : sqlList) {
ExecuteResponse executeResult = executeCommand(originalSql);
result.add(executeResult);
}
return result;
}
private ExecuteResponse executeCommand(String originalSql) {
int pageNo = 1;
int pageSize = 0;
String sqlType = SqlTypeEnum.UNKNOWN.getCode();
ExecuteResponse executeResult = null;
try {
executeResult = doExecuteCommand(originalSql);
} catch (SQLException e) {
throw new IllegalStateException("Redis command execution failed, sql=" + originalSql, e);View on GitHub (pinned to 5ee1e990e7)
Solutions
- Validate that the script is non-blank before submitting to execute
- Show a user-facing message that the command could not be parsed rather than throwing
- Strip comments and whitespace before parsing to avoid empty-list results
Example fix
// before
List<ExecuteResponse> results = executor.execute(command);
// after
if (StringUtils.isBlank(command.getScript())) {
return Collections.emptyList(); // or show user-facing error
}
List<ExecuteResponse> results = executor.execute(command); Defensive patterns
Strategy: validation
Validate before calling
if (command.getScript() == null || command.getScript().isBlank()) {
throw new IllegalArgumentException("Redis script must not be blank");
}
List<ExecuteResponse> results = executor.execute(command); Try / catch
try {
List<ExecuteResponse> results = executor.execute(command);
} catch (BusinessException e) {
if (RedisConstants.ERROR_SQL_ANALYSIS.equals(e.getCode())) {
// show user-facing parse error
}
throw e;
} Prevention
- Validate the script is non-blank before submission
- Test Redis commands against a live instance before scripting them
- Show a user-facing message instead of throwing when the script is empty
When it happens
Trigger: Calling RedisScriptExecutor.execute(SqlExecuteRequest) where command.getScript() is empty, contains only comments/whitespace, or contains text that Druid's parser cannot split into statements. The check at line 123 uses CollectionUtils.isEmpty(sqlList).
Common situations: User submits an empty query in the Redis console; script contains only a semicolon or whitespace; Redis-specific command syntax that the Druid parser does not recognize; copy-paste of a malformed command.
Related errors
- Redis JDBC command arguments cannot contain NUL, CR, or LF
- The baseURL is not valid!
- The baseURL is not valid!
- Data validation failed: ${error.message}
- Missing file
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/a1c052effd97fe61.
Report an issue: GitHub.