Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/pkg/object/command/trino/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func newRequest(r *plugin.Runtime, j *job.Job, c *cluster.Cluster) (*request, er
return nil, err
}
}

Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes clusterCtx.Catalog exists but there's no validation that clusterCtx is not nil or that the Catalog field is populated. This could result in an empty catalog being used if the cluster configuration is missing or incomplete.

Suggested change
// Validate clusterCtx and its Catalog field
if clusterCtx == nil || clusterCtx.Catalog == "" {
return nil, fmt.Errorf("invalid cluster context: missing or empty Catalog")
}

Copilot uses AI. Check for mistakes.
catalog := clusterCtx.Catalog
if jobCtx.Catalog != "" {
catalog = jobCtx.Catalog
}

jobCtx.Query = normalizeTrinoQuery(jobCtx.Query)

// form context for trino request
Expand All @@ -72,7 +78,7 @@ func newRequest(r *plugin.Runtime, j *job.Job, c *cluster.Cluster) (*request, er
`User-Agent`: []string{r.UserAgent},
`X-Trino-User`: []string{j.User},
`X-Trino-Source`: []string{r.UserAgent},
`X-Trino-Catalog`: []string{clusterCtx.Catalog},
`X-Trino-Catalog`: []string{catalog},
},
userAgent: r.UserAgent,
client: &http.Client{},
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/object/command/trino/trino.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type clusterContext struct {
}

type jobContext struct {
Query string `yaml:"query" json:"query"`
Query string `yaml:"query" json:"query"`
Catalog string `yaml:"catalog,omitempty" json:"catalog,omitempty"`
}

// New creates a new trino plugin handler
Expand Down