{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/collections/where.go#L289-L325","documentation":"In `where`, the operator (when provided) must be one of the supported set: `=`, `==`, `eq`, `!=`, `<>`, `ne`, `>=`, `ge`, `>`, `gt`, `<=`, `le`, `<`, `lt`, `in`, `not in`, `intersect`, `like`. The `checkCondition` switch has a `default` branch at where.go:306–307 that fires for any unrecognized operator string.","triggerScenarios":"Passing an unsupported operator string: `{{ where .Pages \"Date\" \"matches\" \"2024\" }}` (use `like` for regex), or a typo like `{{ where .Pages \"Section\" \"equels\" \"blog\" }}`.","commonSituations":"A developer assumes SQL-style operators (`matches`, `contains`, `is`) or mistypes a valid operator. Also common when migrating from another template language's syntax.","solutions":["Use only the supported operators listed in the Hugo docs.","For substring/regex matching use `like` (regex), not `matches` or `contains`.","For membership use `in` or `not in`."],"exampleFix":"// before\n{{ where .Pages \"Title\" \"contains\" \"Hugo\" }}\n// after\n{{ where .Pages \"Title\" \"like\" \"Hugo\" }}","handlingStrategy":"validation","validationCode":"{{ $validOps := slice \"eq\" \"ne\" \"gt\" \"gte\" \"lt\" \"lte\" \"in\" \"not in\" \"like\" \"intersect\" }}\n{{ if in $validOps $op }}\n  {{ where .Pages \"Title\" $op $val }}\n{{ end }}","typeGuard":"func isValidWhereOp(op string) bool {\n    valid := []string{\"\",\"=\",\"==\",\"eq\",\"!=\",\"<>\",\"ne\",\">=\",\"ge\",\">\",\"gt\",\"<=\",\"le\",\"<\",\"lt\",\"in\",\"not in\",\"intersect\",\"like\"}\n    for _, v := range valid { if v == op { return true } }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use only documented where operators.","Use `like` for regex, `in`/`not in` for membership.","Avoid inventing SQL-style operators."],"tags":["hugo","template","collections","where","operator"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}