{"id":"972d28e7e8d65610","repo":"gohugoio/hugo","slug":"no-such-operator","errorCode":null,"errorMessage":"no such operator","messagePattern":"no such operator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/collections/where.go","lineNumber":307,"sourceCode":"\t\t\tif s.Len() > 0 {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, errors.New(\"invalid intersect values\")\n\tcase \"like\":\n\t\tif svp != nil && smvp != nil {\n\t\t\tre, err := hstrings.GetOrCompileRegexp(*smvp)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\tif re.MatchString(*svp) {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}\n\tdefault:\n\t\treturn false, errors.New(\"no such operator\")\n\t}\n\treturn false, nil\n}\n\nfunc evaluateSubElem(ctx, obj reflect.Value, elemName string) (reflect.Value, error) {\n\tif !obj.IsValid() {\n\t\treturn zero, errors.New(\"can't evaluate an invalid value\")\n\t}\n\n\ttyp := obj.Type()\n\tobj, isNil := hreflect.Indirect(obj)\n\n\t// first, check whether obj has a method. In this case, obj is\n\t// a struct or its pointer. If obj is a struct,\n\t// to check all T and *T method, use obj pointer type Value\n\tobjPtr := obj\n\tif !hreflect.IsInterfaceOrPointer(objPtr.Kind()) && objPtr.CanAddr() {\n\t\tobjPtr = objPtr.Addr()","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/collections/where.go#L289-L325","documentation":"The where function's third form takes an operator string; checkCondition dispatches on it and returns this error for anything outside the supported set (=/==/eq, !=/<>/ne, >=/ge, >/gt, <=/le, </lt, in, not in, intersect, like). An unrecognized operator string falls through to the default case.","triggerScenarios":"{{ where $c \"key\" \"op\" $v }} with an unsupported or misspelled operator — e.g. \"===\", \"contains\", \"NOT IN\" (operators are case-sensitive lowercase), \"notin\", \"=~\", or accidentally passing the match value in the operator position in the 3-arg vs 4-arg form.","commonSituations":"Developers from other ecosystems try SQL/JS-style operators; using the 4-argument form when the 3-argument (implicit equality) form was intended shifts the value into the operator slot; \"like\" only exists in newer Hugo versions, so older Hugo rejects it too.","solutions":["Use one of the supported operators exactly: eq/ne/ge/gt/le/lt (or symbol forms), \"in\", \"not in\", \"intersect\", \"like\" — lowercase.","If you meant plain equality, drop the operator: {{ where $pages \"Section\" \"blog\" }}.","If using \"like\", confirm your Hugo version supports it (upgrade if not)."],"exampleFix":"{{/* before */}}\n{{ $posts := where .Site.RegularPages \"Section\" \"===\" \"blog\" }}\n\n{{/* after */}}\n{{ $posts := where .Site.RegularPages \"Section\" \"eq\" \"blog\" }}","handlingStrategy":"validation","validationCode":"{{/* Use only supported where operators */}}\n{{ $ops := slice \"=\" \"==\" \"eq\" \"!=\" \"<>\" \"ne\" \">=\" \"ge\" \">\" \"gt\" \"<=\" \"le\" \"<\" \"lt\" \"in\" \"not in\" \"intersect\" \"like\" }}\n{{ $op := \"in\" }}\n{{ if not (in $ops $op) }}{{ errorf \"unsupported where operator %q\" $op }}{{ end }}\n{{ $r := where site.RegularPages \"Params.tag\" $op (slice \"go\") }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to the documented where operators (eq, ne, ge, gt, le, lt, in, not in, intersect, like)","Operator strings are case/spelling-sensitive — `notin` and `=~` are invalid","When building operators dynamically from config, validate against a whitelist with errorf"],"tags":["hugo","templates","where","operators","collections"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}