{"record":{"id":"1f6b3cf239fbe89e","repo":"t8y2/dbx","slug":"statements-are-required-1f6b3c","errorCode":null,"errorMessage":"statements are required","messagePattern":"statements are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/query.go","lineNumber":301,"sourceCode":"\nfunc (server *server) expireIdleQuerySessions(now time.Time) int {\n\texpired := make([]string, 0)\n\tfor sessionID, state := range server.querySessions {\n\t\tif !state.lastAccessed.IsZero() && now.Sub(state.lastAccessed) >= querySessionIdleTime {\n\t\t\texpired = append(expired, sessionID)\n\t\t}\n\t}\n\tfor _, sessionID := range expired {\n\t\tserver.closeQuerySession(sessionID)\n\t}\n\treturn len(expired)\n}\n\nfunc (server *server) executeStatements(params map[string]json.RawMessage, transaction bool) (queryResult, error) {\n\tstarted := time.Now()\n\tstatements := stringSliceParam(params, \"statements\")\n\tif len(statements) == 0 {\n\t\treturn queryResult{}, errors.New(\"statements are required\")\n\t}\n\tconnection, err := server.requireConnection()\n\tif err != nil {\n\t\treturn queryResult{}, err\n\t}\n\tctx, cancel := queryContext(intParam(params, \"timeoutSecs\"))\n\tserver.setActiveOperation(cancel)\n\tdefer server.clearActiveOperation(cancel)\n\tif err := server.applySchemaContext(ctx, connection, firstNonEmpty(stringParam(params, \"schema\"), stringParam(params, \"database\"))); err != nil {\n\t\treturn queryResult{}, err\n\t}\n\n\tvar affected int64\n\tif transaction {\n\t\ttx, beginErr := connection.BeginTx(ctx, nil)\n\t\tif beginErr == nil {\n\t\t\tfor _, statement := range statements {\n\t\t\t\ttrimmed := trimStatementSQL(statement)","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/query.go#L283-L319","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the JSON params include a non-empty \"statements\" array of SQL strings","Fix the param key spelling — it must be \"statements\" (plural)","Check upstream statement-building logic for empty batches and skip the call instead","Trim/guard statements before sending; note trimStatementSQL empties are rejected later in the loop"],"exampleFix":"// before\nparams := map[string]json.RawMessage{\"timeoutSecs\": json.RawMessage(\"30\")}\nres, err := server.dispatch(ctx, \"execute\", params)\n// after\nparams := map[string]json.RawMessage{\n    \"statements\": json.RawMessage(`[\"SELECT 1\"]`),\n    \"timeoutSecs\": json.RawMessage(\"30\"),\n}\nres, err := server.dispatch(ctx, \"execute\", params)","handlingStrategy":"validation","validationCode":"if len(statements) == 0 {\n    return fmt.Errorf(\"nothing to execute: statements must be non-empty\")\n}\nblob, _ := json.Marshal(statements)\nparams[\"statements\"] = blob","typeGuard":"// Go\nfunc nonEmptyStatements(params map[string]json.RawMessage) bool {\n    s := stringSliceParam(params, \"statements\")\n    return len(s) > 0\n}","tryCatchPattern":null,"preventionTips":["Always build requests through a helper that sets \"statements\" with the plural key","Skip the RPC entirely when the batch is empty after filtering","Unit-test statement builders for the empty-input case"],"tags":["go","hive","validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}