{"record":{"id":"196e643b0e8238f3","repo":"googleapis/mcp-toolbox","slug":"unable-to-retrieve-column-names-w","errorCode":null,"errorMessage":"unable to retrieve column names: %w","messagePattern":"unable to retrieve column names: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/trino/trino.go","lineNumber":125,"sourceCode":"\nfunc (s *Source) ToConfig() sources.SourceConfig {\n\treturn s.Config\n}\n\nfunc (s *Source) TrinoDB() *sql.DB {\n\treturn s.Pool\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {\n\tresults, err := s.TrinoDB().QueryContext(ctx, statement, params...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\n\tdefer results.Close()\n\n\tcols, err := results.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to retrieve column names: %w\", err)\n\t}\n\n\t// create an array of values for each column, which can be re-used to scan each row\n\trawValues := make([]any, len(cols))\n\tvalues := make([]any, len(cols))\n\tfor i := range rawValues {\n\t\tvalues[i] = &rawValues[i]\n\t}\n\n\tout := []any{}\n\tfor results.Next() {\n\t\terr := results.Scan(values...)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse row: %w\", err)\n\t\t}\n\t\tvMap := make(map[string]any)\n\t\tfor i, name := range cols {\n\t\t\tval := rawValues[i]","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/trino/trino.go#L107-L143","documentation":"Trino RunSQL wraps results.Columns() failures. Columns() asks the driver for the result-set column metadata and fails only if the rows handle is invalid or the driver hit a protocol error while fetching metadata. This is rare because the query already succeeded at submission.","triggerScenarios":"Source.RunSQL after a successful QueryContext where results.Columns() fails: result set already closed/corrupted, driver protocol error, or the underlying connection dropped between query submission and metadata fetch.","commonSituations":"Coordinator restart mid-query killing the HTTP session; driver bug with unusual column types (complex Trino types like map/row); extremely wide result sets causing metadata fetch issues.","solutions":["Check the wrapped error and retry the query — this is often transient","Upgrade the trino-go-client driver to the latest version","Avoid exotic result shapes (very wide rows, complex types) if reproducible","Verify coordinator stability and proxy timeouts between client and Trino"],"exampleFix":"// before\n// no retry on metadata errors\n// after\ncols, err := results.Columns()\nif err != nil && isTransient(err) {\n    cols, err = retryQuery(ctx, statement, params)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := src.RunSQL(ctx, stmt, params)\nif err != nil && strings.Contains(err.Error(), \"unable to retrieve column names\") {\n    // usually transient: retry once with a fresh query\n    out, err = src.RunSQL(ctx, stmt, params)\n}","preventionTips":["Keep trino-go-client up to date","Avoid SELECT * over tables with complex nested types when the consumer is the toolbox","Ensure coordinator and proxies don't kill connections between submit and metadata fetch","Add a bounded retry for metadata-stage failures"],"tags":["database","trino","result-metadata","row-iteration"],"backgroundTag":"rows-iteration-error","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}