{"record":{"id":"75db4f7ec7a69803","repo":"t8y2/dbx","slug":"sql-is-required-75db4f","errorCode":null,"errorMessage":"SQL is required","messagePattern":"SQL is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-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/argo-go/query.go#L15-L51","documentation":"executeQuery is the central query entry point. It trims the provided SQL and rejects empty statements with this error before acquiring the connection, applying default fetch size and max rows. This prevents issuing meaningless empty statements to HiveServer2.","triggerScenarios":"Calling executeQuery (directly or via dispatch, connectionInfo, listDatabases, listTables, listRoutines, getColumns) with queryOptions.SQL set to \"\" or whitespace-only after trimStatementSQL.","commonSituations":"Client submits an empty query box; a template variable interpolates to nothing; a metadata helper builds SQL from an empty name; request params omit the sql field so queryOptions.SQL is the zero value.","solutions":["Set queryOptions.SQL to a non-empty statement before calling executeQuery","Validate the SQL field on the client/request layer before dispatch","Check that SQL-building helpers (e.g. SHOW queries with interpolated names) receive non-empty inputs","Log the trimmed SQL to confirm what actually reaches executeQuery when debugging"],"exampleFix":"// before\nres, err := server.executeQuery(queryOptions{SQL: req.SQL}) // req.SQL == \"\"\n// after\nif strings.TrimSpace(req.SQL) == \"\" {\n    return errors.New(\"SQL is required\")\n}\nres, err := server.executeQuery(queryOptions{SQL: req.SQL})","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(options.SQL) == \"\" {\n    return errors.New(\"SQL is required\")\n}","typeGuard":null,"tryCatchPattern":"res, err := server.executeQuery(queryOptions{SQL: sql, MaxRows: 100})\nif err != nil && err.Error() == \"SQL is required\" {\n    return fmt.Errorf(\"query rejected: empty SQL\")\n}","preventionTips":["Validate SQL before dispatch at the client layer","Ensure SQL-building helpers always interpolate non-empty values","Require the sql field in request params schema","Log trimmed SQL when debugging empty-query rejections"],"tags":["validation","sql","query"],"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"}