{"record":{"id":"d45d3497abdcc097","repo":"zitadel/zitadel","slug":"missing-column","errorCode":null,"errorMessage":"missing column","messagePattern":"missing column","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/query/search_query.go","lineNumber":284,"sourceCode":"\tif col.isZero() {\n\t\treturn nil, ErrMissingColumn\n\t}\n\treturn &InTextQuery{\n\t\tColumn: col,\n\t\tValues: values,\n\t}, nil\n}\n\ntype textQuery struct {\n\tColumn  Column\n\tText    string\n\tCompare TextComparison\n}\n\nvar (\n\tErrNothingSelected = errors.New(\"nothing selected\")\n\tErrInvalidCompare  = errors.New(\"invalid compare\")\n\tErrMissingColumn   = errors.New(\"missing column\")\n\tErrInvalidNumber   = errors.New(\"value is no number\")\n\tErrEmptyValues     = errors.New(\"values array must not be empty\")\n)\n\nfunc NewTextQuery(col Column, value string, compare TextComparison) (*textQuery, error) {\n\tif compare < 0 || compare >= textCompareMax {\n\t\treturn nil, ErrInvalidCompare\n\t}\n\tif col.isZero() {\n\t\treturn nil, ErrMissingColumn\n\t}\n\t// handle the comparisons which use (i)like and therefore need to escape potential wildcards in the value\n\tswitch compare {\n\tcase TextStartsWith,\n\t\tTextStartsWithIgnoreCase,\n\t\tTextEndsWith,\n\t\tTextEndsWithIgnoreCase,\n\t\tTextContains,","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/zitadel/zitadel/blob/13948f2bcd6f257794dbd6d342c2ac30bc88fe54/internal/query/search_query.go#L266-L302","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","solutions":["Ensure the Column is constructed via its proper constructor (e.g. NewColumn(tableName, colName)) before passing it to query builders","Validate request-derived column names at the API layer and reject empty values with a descriptive error","Handle errors.Is(err, query.ErrMissingColumn) to surface which filter was missing its column"],"exampleFix":"// before\nvar col query.Column // zero value\nq, err := query.NewNotNullQuery(col)\n// after\ncol, err := query.NewColumn(\"users\", \"id\")\nif err != nil {\n    return err\n}\nq, err := query.NewNotNullQuery(col)","handlingStrategy":"validation","validationCode":"if col.IsZero() { // if IsZero is exported on your Column wrapper\n\treturn nil, fmt.Errorf(\"filter %q: column is required\", filterName)\n}\nq, err := query.NewIsNullQuery(col)","typeGuard":"func hasColumn(c query.Column) bool {\n\treturn !c.isZero() // wrap in the query package or expose a helper\n}","tryCatchPattern":"q, err := query.NewNotNullQuery(col)\nif err != nil {\n\tif errors.Is(err, query.ErrMissingColumn) {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"filter column must not be empty\")\n\t}\n\treturn err\n}","preventionTips":["Construct Columns only via NewColumn/table helpers, never as zero values","Validate optional request fields that feed column names before building queries","Fail at unmarshal time on empty column names instead of at query construction"],"tags":["go","query","sql","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"13948f2bcd6f257794dbd6d342c2ac30bc88fe54","analyzedAt":"2026-09-06T10:16:19.814Z","contentChangedAt":"2026-09-06T10:16:19.814Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}