{"record":{"id":"8ea69a70bab8d8c1","repo":"projectdiscovery/nuclei","slug":"case-insensitive-flag-is-supported-only-for-word","errorCode":null,"errorMessage":"case-insensitive flag is supported only for 'word' matchers (not '%s')","messagePattern":"case-insensitive flag is supported only for 'word' matchers \\(not '(.+?)'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/operators/matchers/compile.go","lineNumber":94,"sourceCode":"\t\t\treturn &dsl.CompilationError{DslSignature: dslExpression, WrappedError: err}\n\t\t}\n\t\t_ = cache.DSL().Set(dslExpression, compiledExpression)\n\t\tmatcher.dslCompiled = append(matcher.dslCompiled, compiledExpression)\n\t}\n\n\t// Set up the condition type, if any.\n\tif matcher.Condition != \"\" {\n\t\tmatcher.condition, ok = ConditionTypes[matcher.Condition]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unknown condition specified: %s\", matcher.Condition)\n\t\t}\n\t} else {\n\t\tmatcher.condition = ORCondition\n\t}\n\n\tif matcher.CaseInsensitive {\n\t\tif matcher.GetType() != WordsMatcher {\n\t\t\treturn fmt.Errorf(\"case-insensitive flag is supported only for 'word' matchers (not '%s')\", matcher.Type)\n\t\t}\n\t\tfor i := range matcher.Words {\n\t\t\tmatcher.Words[i] = strings.ToLower(matcher.Words[i])\n\t\t}\n\t}\n\treturn nil\n}\n\n// GetType returns the condition type of the matcher\n// todo: the field should be exposed natively\nfunc (matcher *Matcher) GetCondition() ConditionType {\n\treturn matcher.condition\n}\n","sourceCodeStart":76,"sourceCodeEnd":108,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/operators/matchers/compile.go#L76-L108","documentation":"Template compilation error from Matcher.CompileMatchers (pkg/operators/matchers/compile.go:94). `case-insensitive: true` is only implemented for `type: word` matchers (words are lowercased at compile time); on any other matcher type it is rejected rather than ignored, so the author does not mistakenly believe the flag applies.","triggerScenarios":"A matcher with `type: regex`/`binary`/`dsl`/`status`/`size`/`xpath` that also sets `case-insensitive: true`.","commonSituations":"Copy-pasting a word matcher and switching only the type; attempting case-insensitive regex matching via the flag instead of '(?i)'.","solutions":["For regex matchers, use the inline RE2 flag: '(?i)pattern'","For DSL matchers, normalize with to_lower(...) on both sides","Restrict `case-insensitive: true` to word matchers only","Validate with `nuclei -validate -t template.yaml`"],"exampleFix":"# before\nmatchers:\n  - type: regex\n    case-insensitive: true\n    regex:\n      - 'Apache/2\\.4'\n# after\nmatchers:\n  - type: regex\n    regex:\n      - '(?i)apache/2\\.4'","handlingStrategy":"validation","validationCode":"if m.CaseInsensitive && m.GetType() != ma.WordsMatcher {\n\treturn fmt.Errorf(\"case-insensitive only valid on word matchers, got %v\", m.Type)\n}","typeGuard":"func matcherAllowsCaseInsensitive(t string) bool { return strings.ToLower(strings.TrimSpace(t)) == \"word\" }","tryCatchPattern":"if err := m.CompileMatchers(); err != nil && strings.Contains(err.Error(), \"case-insensitive flag is supported only for 'word' matchers\") {\n\t// convert to (?i) regex or to_lower() DSL and recompile\n}","preventionTips":["Matcher flag => word only; extractor flag => kval only","Use (?i) inline for regex case-insensitivity","Validate templates before merge"],"tags":["matcher","case-insensitive","template","compile-time","validation"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}