t8y2/dbx · error

statements are required

Error message

statements are required

What it means

executeStatements requires the request's 'statements' parameter to be a non-empty JSON array of SQL strings. When the parameter is missing, empty, or an empty slice, the driver refuses to connect/execute because there is nothing to run.

Source

Thrown at agents/drivers/hive-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

  1. Ensure the JSON params include a non-empty "statements" array of SQL strings
  2. Fix the param key spelling — it must be "statements" (plural)
  3. Check upstream statement-building logic for empty batches and skip the call instead
  4. Trim/guard statements before sending; note trimStatementSQL empties are rejected later in the loop

Example fix

// before
params := map[string]json.RawMessage{"timeoutSecs": json.RawMessage("30")}
res, err := server.dispatch(ctx, "execute", params)
// after
params := map[string]json.RawMessage{
    "statements": json.RawMessage(`["SELECT 1"]`),
    "timeoutSecs": json.RawMessage("30"),
}
res, err := server.dispatch(ctx, "execute", params)
Defensive patterns

Strategy: validation

Validate before calling

if len(statements) == 0 {
    return fmt.Errorf("nothing to execute: statements must be non-empty")
}
blob, _ := json.Marshal(statements)
params["statements"] = blob

Type guard

// Go
func nonEmptyStatements(params map[string]json.RawMessage) bool {
    s := stringSliceParam(params, "statements")
    return len(s) > 0
}

Prevention

When it happens

Trigger: Calling the query/execute endpoint (or transaction path) with params lacking 'statements', with an empty array [], or with an array of only whitespace statements that stringSliceParam resolves to zero entries.

Common situations: Client serializes an empty batch after filtering statements; JSON body uses the wrong key name (e.g. 'statement' singular); a template produced no SQL for this run.

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


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/1f6b3cf239fbe89e. Report an issue: GitHub.