{"record":{"id":"35c0677efd8b9ff5","repo":"t8y2/dbx","slug":"statements-are-required","errorCode":null,"errorMessage":"statements are required","messagePattern":"statements are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-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/argo-go/query.go#L283-L319","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nresult, err := executeStatements(ctx, map[string]json.RawMessage{\"statements\": mustJSON(stmts)})\n// after\nif len(stmts) == 0 {\n    return nil // nothing to run\n}\nresult, err := executeStatements(ctx, map[string]json.RawMessage{\"statements\": mustJSON(stmts)})","handlingStrategy":"validation","validationCode":"if len(stmts) == 0 {\n    return nil // or an app-level \"nothing to execute\"\n}","typeGuard":null,"tryCatchPattern":"result, err := executeStatements(ctx, params)\nif err != nil && strings.Contains(err.Error(), \"statements are required\") {\n    // report missing/empty batch to the caller\n}","preventionTips":["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"],"tags":["validation","batch","transaction","go"],"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-14T05:17:10.506Z"}