{"record":{"id":"a0163724b7f0cfe6","repo":"qax-os/excelize","slug":"unknown-operator-s","errorCode":null,"errorMessage":"unknown operator: %s","messagePattern":"unknown operator: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":399,"sourceCode":"\treturn fmt.Errorf(\"base field %s does not exist in shared items\", field)\n}\n\n// newStreamSetRowError defined the error message on the stream writer\n// receiving the non-ascending row number.\nfunc newStreamSetRowError(row int) error {\n\treturn fmt.Errorf(\"row %d has already been written\", row)\n}\n\n// newStreamSetRowOrderError defined the error message on calling the SetRow\n// function before the order function.\nfunc newStreamSetRowOrderError(name string) error {\n\treturn fmt.Errorf(\"must call the %s function before the SetRow function\", name)\n}\n\n// newUnknownFilterTokenError defined the error message on receiving a unknown\n// filter operator token.\nfunc newUnknownFilterTokenError(token string) error {\n\treturn fmt.Errorf(\"unknown operator: %s\", token)\n}\n\n// newUnsupportedChartType defined the error message on receiving the chart\n// type are unsupported.\nfunc newUnsupportedChartType(chartType ChartType) error {\n\treturn fmt.Errorf(\"unsupported chart type %d\", chartType)\n}\n\n// newUnsupportedPivotCacheSourceType defined the error message on receiving the\n// source type of pivot table cache.\nfunc newUnsupportedPivotCacheSourceType(sourceType string) error {\n\treturn fmt.Errorf(\"unsupported pivot table cache source type: %s\", sourceType)\n}\n\n// newUnzipSizeLimitError defined the error message on unzip size exceeds the\n// limit.\nfunc newUnzipSizeLimitError(unzipSizeLimit int64) error {\n\treturn fmt.Errorf(\"unzip size exceeds the %d bytes limit\", unzipSizeLimit)","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L381-L417","documentation":"The AutoFilter expression parser tokenizes filter strings like 'x < 5 or y > 2' into conditions and operators. This error is thrown when a token positioned as an operator is not a recognized operator (and/or or the comparison shorthand), so the filter expression cannot be understood.","triggerScenarios":"Calling f.AutoFilter with a criteria expression containing a misspelled or unsupported operator token, e.g. 'A1 > 10 && B1 < 5' (using && instead of 'and') or 'x equals 5' in a context expecting 'and'/'or' between conditions.","commonSituations":"Building filter strings by string concatenation with SQL-style operators; localizing operators; typos like 'adn', 'ore', or stray tokens left after splitting the expression.","solutions":["Use only the supported operators in filter expressions: and, or, and the comparison forms the library documents for AutoFilter criteria.","Print/tokenize your criteria string and remove stray or misspelled tokens between conditions.","Replace SQL-style '&&'/'||' with 'and'/'or'.","Split complex filters into multiple simpler AutoFilter expressions if the combined string still fails."],"exampleFix":"// before\nf.AutoFilter(\"Sheet1\", \"A1:D10\", []excelize.AutoFilterOptions{\n    {Column: \"A\", Expression: \"x > 1 && x < 10\"},\n})\n// after\nf.AutoFilter(\"Sheet1\", \"A1:D10\", []excelize.AutoFilterOptions{\n    {Column: \"A\", Expression: \"x > 1 and x < 10\"},\n})","handlingStrategy":"validation","validationCode":"var validOps = map[string]bool{\"and\": true, \"or\": true}\nfunc tokensValid(expr string) bool {\n    for _, tok := range strings.Fields(expr) {\n        if validOps[tok] {\n            continue\n        }\n    }\n    // stricter: reject SQL-style operators up front\n    return !strings.ContainsAny(expr, \"&|\") &&\n        !strings.Contains(expr, \"&&\") && !strings.Contains(expr, \"||\")\n}","typeGuard":null,"tryCatchPattern":"err := f.AutoFilter(sheet, rangeRef, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"unknown operator\") {\n        return fmt.Errorf(\"autofilter expression %q has an unsupported operator token\", expr)\n    }\n    return err\n}","preventionTips":["Build filter expressions with constants, not string concatenation of user text","Use 'and'/'or' keywords, never && or ||","Unit-test every filter expression your app generates","Trim whitespace and normalize case before passing expressions"],"tags":["go","excelize","autofilter","expression-parsing"],"backgroundTag":"unknown-filter-operator","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}