{"record":{"id":"74d3f195f6168c63","repo":"t8y2/dbx","slug":"sql-is-required-74d3f1","errorCode":null,"errorMessage":"SQL is required","messagePattern":"SQL is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/query.go","lineNumber":33,"sourceCode":"\nfunc (server *server) validateConnection() error {\n\tconnection, err := server.requireConnection()\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), server.config.ConnectTimeout)\n\tdefer cancel()\n\treturn connection.PingContext(ctx)\n}\n\nfunc (server *server) executeQuery(options queryOptions) (queryResult, error) {\n\tstarted := time.Now()\n\tif options.FetchSize <= 0 {\n\t\toptions.FetchSize = server.effectiveFetchSize()\n\t}\n\tsqlText := trimStatementSQL(options.SQL)\n\tif sqlText == \"\" {\n\t\treturn queryResult{}, errors.New(\"SQL is required\")\n\t}\n\tmaxRows := options.MaxRows\n\tif maxRows <= 0 {\n\t\tmaxRows = defaultMaxRows\n\t}\n\tconnection, err := server.requireConnection()\n\tif err != nil {\n\t\treturn queryResult{}, err\n\t}\n\n\tctx, cancel := queryContext(options.TimeoutSecs)\n\tserver.setActiveOperation(cancel)\n\tdefer server.clearActiveOperation(cancel)\n\tif err := server.applySchemaContext(ctx, connection, effectiveSchema(options)); err != nil {\n\t\treturn queryResult{}, err\n\t}\n\trows, affected, hasResultSet, err := executeHiveStatement(ctx, connection, sqlText, options.FetchSize)\n\tif err != nil {","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/query.go#L15-L51","documentation":"executeQuery() normalizes options.SQL with trimStatementSQL and rejects empty statements before acquiring a connection. Any dispatch-style query with blank SQL fails immediately with \"SQL is required\" — a request-shape validation error, not a server error.","triggerScenarios":"Calling executeQuery (directly or via dispatch, connectionInfo, listDatabases, listTables, listRoutines, getColumns paths) with options.SQL empty, whitespace-only, or containing only content that trims away.","commonSituations":"Template-driven SQL builders emitting empty strings when parameters are missing; request handlers forwarding empty body SQL; connectionInfo built from a config where the probe query variable is unset.","solutions":["Set a non-empty SQL string in queryOptions before calling executeQuery.","Validate/trim the SQL in your caller and return a client-side error when blank.","Check the code path that builds queryOptions for listDatabases/listTables etc. — a config field feeding the probe query may be empty.","Ensure trimStatementSQL isn't unexpectedly emptying statements that are comment-only."],"exampleFix":"// before\nres, err := executeQuery(queryOptions{SQL: \"\"})\n// after\nsql := strings.TrimSpace(userSQL)\nif sql == \"\" {\n    return errors.New(\"please provide a SQL statement\")\n}\nres, err := executeQuery(queryOptions{SQL: sql})","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(sql) == \"\" {\n    return errors.New(\"SQL statement is required\")\n}","typeGuard":null,"tryCatchPattern":"res, err := srv.Dispatch(queryOptions{SQL: sql})\nif err != nil && strings.Contains(err.Error(), \"SQL is required\") {\n    return fmt.Errorf(\"empty query rejected: check SQL builder output\")\n}","preventionTips":["Assert SQL builders never emit empty strings (unit-test templates with missing params).","Validate request bodies for the sql field.","Check config values feeding probe queries in connectionInfo/listDatabases."],"tags":["hive","validation","sql","missing-argument","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-14T00:17:10.932Z"}