t8y2/dbx · error
statements are required
Error message
statements are required
What it means
executeStatements requires at least one statement in the JSON param "statements"; when the list is empty or missing it returns this error before opening a connection or beginning a transaction. Batch execution with zero statements is treated as a caller bug, not a no-op.
Source
Thrown at agents/drivers/argo-go/query.go:301
func (server *server) expireIdleQuerySessions(now time.Time) int {
expired := make([]string, 0)
for sessionID, state := range server.querySessions {
if !state.lastAccessed.IsZero() && now.Sub(state.lastAccessed) >= querySessionIdleTime {
expired = append(expired, sessionID)
}
}
for _, sessionID := range expired {
server.closeQuerySession(sessionID)
}
return len(expired)
}
func (server *server) executeStatements(params map[string]json.RawMessage, transaction bool) (queryResult, error) {
started := time.Now()
statements := stringSliceParam(params, "statements")
if len(statements) == 0 {
return queryResult{}, errors.New("statements are required")
}
connection, err := server.requireConnection()
if err != nil {
return queryResult{}, err
}
ctx, cancel := queryContext(intParam(params, "timeoutSecs"))
server.setActiveOperation(cancel)
defer server.clearActiveOperation(cancel)
if err := server.applySchemaContext(ctx, connection, firstNonEmpty(stringParam(params, "schema"), stringParam(params, "database"))); err != nil {
return queryResult{}, err
}
var affected int64
if transaction {
tx, beginErr := connection.BeginTx(ctx, nil)
if beginErr == nil {
for _, statement := range statements {
trimmed := trimStatementSQL(statement)View on GitHub (pinned to c0390bff16)
Solutions
- Pass at least one SQL statement in the "statements" array
- Guard at the call site: skip the call (or return success) when the statement list is empty
- Fix the code that builds the statement list so empty batches are handled before dispatch
Example fix
// before
result, err := executeStatements(ctx, map[string]json.RawMessage{"statements": mustJSON(stmts)})
// after
if len(stmts) == 0 {
return nil // nothing to run
}
result, err := executeStatements(ctx, map[string]json.RawMessage{"statements": mustJSON(stmts)}) Defensive patterns
Strategy: validation
Validate before calling
if len(stmts) == 0 {
return nil // or an app-level "nothing to execute"
} Try / catch
result, err := executeStatements(ctx, params)
if err != nil && strings.Contains(err.Error(), "statements are required") {
// report missing/empty batch to the caller
} Prevention
- Guard empty statement batches before dispatch
- Validate JSON request bodies for the required statements field
- Treat zero-statement batches as a no-op at the service layer
When it happens
Trigger: Calling the statements/transaction dispatch with params missing the "statements" key, or with "statements": [] (empty array); building the param programmatically from a slice that was empty.
Common situations: Transaction wrappers that collect statements into a slice which ended up empty due to filtering; JSON bodies from HTTP clients omitting the field; migration tools finding no pending statements and still calling execute.
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
- Hive connection string must start with jdbc:hive2:// or hive
- token is empty
- ZooKeeper server list is empty
- ETCD_WATCH_SCOPE_INVALID
- lease, ttl, and preserveLease cannot be specified together
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/35c0677efd8b9ff5.
Report an issue: GitHub.