{"record":{"id":"dfcdb697b812ab47","repo":"projectdiscovery/nuclei","slug":"case-insensitive-flag-is-supported-only-for-kval","errorCode":null,"errorMessage":"case-insensitive flag is supported only for 'kval' extractors (not '%s')","messagePattern":"case-insensitive flag is supported only for 'kval' extractors \\(not '(.+?)'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/operators/extractors/compile.go","lineNumber":71,"sourceCode":"\t\te.jsonCompiled = append(e.jsonCompiled, compiled)\n\t}\n\n\tfor _, dslExp := range e.DSL {\n\t\tif cached, err := cache.DSL().GetIFPresent(dslExp); err == nil && cached != nil {\n\t\t\te.dslCompiled = append(e.dslCompiled, cached)\n\t\t\tcontinue\n\t\t}\n\t\tcompiled, err := govaluate.NewEvaluableExpressionWithFunctions(dslExp, dsl.HelperFunctions)\n\t\tif err != nil {\n\t\t\treturn &dsl.CompilationError{DslSignature: dslExp, WrappedError: err}\n\t\t}\n\t\t_ = cache.DSL().Set(dslExp, compiled)\n\t\te.dslCompiled = append(e.dslCompiled, compiled)\n\t}\n\n\tif e.CaseInsensitive {\n\t\tif e.GetType() != KValExtractor {\n\t\t\treturn fmt.Errorf(\"case-insensitive flag is supported only for 'kval' extractors (not '%s')\", e.Type)\n\t\t}\n\t\tfor i := range e.KVal {\n\t\t\te.KVal[i] = strings.ToLower(e.KVal[i])\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":53,"sourceCodeEnd":80,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/operators/extractors/compile.go#L53-L80","documentation":"Template compilation error from Extractor.CompileExtractors (pkg/operators/extractors/compile.go:71). `case-insensitive: true` is only implemented for kval extractors (keys are lowercased at compile time, lines 41–43, and again at 71–76). Setting it on any other extractor type is rejected instead of being silently ignored.","triggerScenarios":"An extractor with `type: regex`/`dsl`/`json`/`xpath` that also sets `case-insensitive: true`.","commonSituations":"Copy-pasting a kval extractor and changing only `type:`; trying to make a word/regex match case-insensitive using the matcher-style flag on the wrong object; templates authored against older nuclei that tolerated the flag.","solutions":["For regex/dsl: implement case-insensitivity in the expression itself — '(?i)pattern' for regex or to_lower(...) in DSL","For kval: keep `case-insensitive: true` and ensure `type: kval`","Remove the flag from non-kval extractors to restore compilation","Validate with `nuclei -validate -t template.yaml`"],"exampleFix":"# before\nextractors:\n  - type: regex\n    case-insensitive: true\n    regex:\n      - 'Root: '\n# after\nextractors:\n  - type: regex\n    regex:\n      - '(?i)root: '","handlingStrategy":"validation","validationCode":"if ex.CaseInsensitive && ex.GetType() != ea.KValExtractor {\n\treturn fmt.Errorf(\"case-insensitive only valid on kval extractors, got %v\", ex.Type)\n}","typeGuard":"func caseInsensitiveAllowed(t string) bool { return strings.ToLower(strings.TrimSpace(t)) == \"kval\" }","tryCatchPattern":"if err := ex.CompileExtractors(); err != nil && strings.Contains(err.Error(), \"case-insensitive flag is supported only\") {\n\t// drop the flag and bake (?i)/to_lower into the pattern/expression instead\n}","preventionTips":["Remember: extractor flag => kval only; matcher flag => word only","Use (?i) for regex and to_lower() for DSL instead of the flag","Run -validate to catch copy-paste type flips"],"tags":["extractor","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"}