zitadel/zitadel · error

missing column

Error message

missing column

What it means

ErrMissingColumn is returned by query constructors (NewNotNullQuery, NewIsNullQuery, NewOrQuery, NewAndQuery, NewNotQuery, NewColumnComparisonQuery, NewTextQuery, NewNumberQuery, etc.) when the Column argument is the zero value. A zero Column has no table/name identifier, so it cannot be rendered into valid SQL.

Source

Thrown at internal/query/search_query.go:284

	if col.isZero() {
		return nil, ErrMissingColumn
	}
	return &InTextQuery{
		Column: col,
		Values: values,
	}, nil
}

type textQuery struct {
	Column  Column
	Text    string
	Compare TextComparison
}

var (
	ErrNothingSelected = errors.New("nothing selected")
	ErrInvalidCompare  = errors.New("invalid compare")
	ErrMissingColumn   = errors.New("missing column")
	ErrInvalidNumber   = errors.New("value is no number")
	ErrEmptyValues     = errors.New("values array must not be empty")
)

func NewTextQuery(col Column, value string, compare TextComparison) (*textQuery, error) {
	if compare < 0 || compare >= textCompareMax {
		return nil, ErrInvalidCompare
	}
	if col.isZero() {
		return nil, ErrMissingColumn
	}
	// handle the comparisons which use (i)like and therefore need to escape potential wildcards in the value
	switch compare {
	case TextStartsWith,
		TextStartsWithIgnoreCase,
		TextEndsWith,
		TextEndsWithIgnoreCase,
		TextContains,

View on GitHub (pinned to 13948f2bcd)

Solutions

  1. Ensure the Column is constructed via its proper constructor (e.g. NewColumn(tableName, colName)) before passing it to query builders
  2. Validate request-derived column names at the API layer and reject empty values with a descriptive error
  3. Handle errors.Is(err, query.ErrMissingColumn) to surface which filter was missing its column

Example fix

// before
var col query.Column // zero value
q, err := query.NewNotNullQuery(col)
// after
col, err := query.NewColumn("users", "id")
if err != nil {
    return err
}
q, err := query.NewNotNullQuery(col)
Defensive patterns

Strategy: validation

Validate before calling

if col.IsZero() { // if IsZero is exported on your Column wrapper
	return nil, fmt.Errorf("filter %q: column is required", filterName)
}
q, err := query.NewIsNullQuery(col)

Type guard

func hasColumn(c query.Column) bool {
	return !c.isZero() // wrap in the query package or expose a helper
}

Try / catch

q, err := query.NewNotNullQuery(col)
if err != nil {
	if errors.Is(err, query.ErrMissingColumn) {
		return nil, status.Error(codes.InvalidArgument, "filter column must not be empty")
	}
	return err
}

Prevention

When it happens

Trigger: Passing a zero-value Column (e.g. declaring var col query.Column and forgetting to assign, or a struct field of type Column left unset when assembling filters programmatically) to any of the New*Query constructors that call col.isZero().

Common situations: Building search queries dynamically from request DTOs where the column name field was optional or empty; Go zero values silently propagate into the constructor instead of being caught at unmarshaling time.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of zitadel/zitadel@13948f2bcd (2026-09-06). Data as JSON: /api/errors/d45d3497abdcc097. Report an issue: GitHub.