{"record":{"id":"43719c5b4a783434","repo":"t8y2/dbx","slug":"statements-are-required-43719c","errorCode":null,"errorMessage":"statements are required","messagePattern":"statements are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/query.go","lineNumber":318,"sourceCode":"\t\tif err := state.dataset.Close(); err != nil && firstErr == nil {\n\t\t\tfirstErr = err\n\t\t}\n\t\tdelete(s.querySessions, sessionID)\n\t}\n\treturn firstErr\n}\n\nfunc (s *server) executeStatements(params map[string]json.RawMessage, transaction bool) (queryResult, error) {\n\tif transaction {\n\t\t// IoTDB executes statements independently and exposes no rollbackable\n\t\t// transaction boundary. Reject the RPC before obtaining a client so a\n\t\t// requested atomic batch can never leave partial writes behind.\n\t\treturn queryResult{}, errors.New(\"IoTDB does not support transactions\")\n\t}\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\tdatabase := strings.TrimSpace(stringParam(params, \"schema\"))\n\tfor _, statement := range statements {\n\t\tsql := trimStatementSQL(statement)\n\t\tif sql == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif isQueryStatement(sql) {\n\t\t\tvalues, err := s.queryValues(sql, database, defaultMaxRows, 0)\n\t\t\tif err != nil {\n\t\t\t\treturn queryResult{}, err\n\t\t\t}\n\t\t\t_ = values\n\t\t} else if err := s.executeNonQuery(sql, database, 0); err != nil {\n\t\t\treturn queryResult{}, err\n\t\t}\n\t}\n\treturn queryResult{","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/query.go#L300-L336","documentation":"executeStatements validates that the 'statements' parameter carries at least one entry before doing any work. An empty (or missing) statements array yields nothing to execute, so the RPC fails fast with this error.","triggerScenarios":"Calling the statement-execution RPC with 'statements' absent, null, or an empty array (stringSliceParam returns zero entries).","commonSituations":"A caller builds the statement list dynamically and all statements were filtered out as empty; a wiring/config mistake drops the statements field from the RPC params; a template renders zero SQL statements.","solutions":["Ensure the 'statements' parameter is a non-empty array of SQL strings before calling the RPC","Filter empty statements before sending; if the filtered list is empty, skip the call entirely","Validate the RPC payload at the call site and fail with a clearer application-level message"],"exampleFix":"// before\nexecuteStatements(map[string]json.RawMessage{\"statements\": nil}, false)\n// after\nif len(stmts) == 0 { return nil } // skip the call\nexecuteStatements(map[string]json.RawMessage{\"statements\": mustMarshal(stmts)}, false)","handlingStrategy":"validation","validationCode":"if len(statements) == 0 { return errors.New(\"no statements to execute\") }","typeGuard":null,"tryCatchPattern":"res, err := executeStatements(params, false); if err != nil && err.Error() == \"statements are required\" { /* fix payload construction */ }","preventionTips":["Validate the statements array is non-empty before every RPC call","Trim and drop blank statements before sending; skip the call if nothing remains","Log the outgoing params when a validation error occurs to catch payload-construction bugs"],"tags":["validation","parameters","iotdb"],"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"}