t8y2/dbx · error
SQL is required
Error message
SQL is required
What it means
executeQuery() normalizes options.SQL with trimStatementSQL and rejects empty statements before acquiring a connection. Any dispatch-style query with blank SQL fails immediately with "SQL is required" — a request-shape validation error, not a server error.
Source
Thrown at agents/drivers/hive-go/query.go:33
func (server *server) validateConnection() error {
connection, err := server.requireConnection()
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), server.config.ConnectTimeout)
defer cancel()
return connection.PingContext(ctx)
}
func (server *server) executeQuery(options queryOptions) (queryResult, error) {
started := time.Now()
if options.FetchSize <= 0 {
options.FetchSize = server.effectiveFetchSize()
}
sqlText := trimStatementSQL(options.SQL)
if sqlText == "" {
return queryResult{}, errors.New("SQL is required")
}
maxRows := options.MaxRows
if maxRows <= 0 {
maxRows = defaultMaxRows
}
connection, err := server.requireConnection()
if err != nil {
return queryResult{}, err
}
ctx, cancel := queryContext(options.TimeoutSecs)
server.setActiveOperation(cancel)
defer server.clearActiveOperation(cancel)
if err := server.applySchemaContext(ctx, connection, effectiveSchema(options)); err != nil {
return queryResult{}, err
}
rows, affected, hasResultSet, err := executeHiveStatement(ctx, connection, sqlText, options.FetchSize)
if err != nil {View on GitHub (pinned to c0390bff16)
Solutions
- Set a non-empty SQL string in queryOptions before calling executeQuery.
- Validate/trim the SQL in your caller and return a client-side error when blank.
- Check the code path that builds queryOptions for listDatabases/listTables etc. — a config field feeding the probe query may be empty.
- Ensure trimStatementSQL isn't unexpectedly emptying statements that are comment-only.
Example fix
// before
res, err := executeQuery(queryOptions{SQL: ""})
// after
sql := strings.TrimSpace(userSQL)
if sql == "" {
return errors.New("please provide a SQL statement")
}
res, err := executeQuery(queryOptions{SQL: sql}) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(sql) == "" {
return errors.New("SQL statement is required")
} Try / catch
res, err := srv.Dispatch(queryOptions{SQL: sql})
if err != nil && strings.Contains(err.Error(), "SQL is required") {
return fmt.Errorf("empty query rejected: check SQL builder output")
} Prevention
- Assert SQL builders never emit empty strings (unit-test templates with missing params).
- Validate request bodies for the sql field.
- Check config values feeding probe queries in connectionInfo/listDatabases.
When it happens
Trigger: Calling executeQuery (directly or via dispatch, connectionInfo, listDatabases, listTables, listRoutines, getColumns paths) with options.SQL empty, whitespace-only, or containing only content that trims away.
Common situations: Template-driven SQL builders emitting empty strings when parameters are missing; request handlers forwarding empty body SQL; connectionInfo built from a config where the probe query variable is unset.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- table is required
- SQL is required
- Hive connection string must start with jdbc:hive2:// or hive
- token is empty
- statements are required
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/74d3f195f6168c63.
Report an issue: GitHub.