{"record":{"id":"ad51ead9509c14b6","repo":"projectdiscovery/nuclei","slug":"unknown-condition-specified-s","errorCode":null,"errorMessage":"unknown condition specified: %s","messagePattern":"unknown condition specified: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/operators/matchers/compile.go","lineNumber":86,"sourceCode":"\t// Compile the dsl expressions (with shared cache)\n\tfor _, dslExpression := range matcher.DSL {\n\t\tif cached, err := cache.DSL().GetIFPresent(dslExpression); err == nil && cached != nil {\n\t\t\tmatcher.dslCompiled = append(matcher.dslCompiled, cached)\n\t\t\tcontinue\n\t\t}\n\t\tcompiledExpression, err := govaluate.NewEvaluableExpressionWithFunctions(dslExpression, dsl.HelperFunctions)\n\t\tif err != nil {\n\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","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/operators/matchers/compile.go#L68-L104","documentation":"Template compilation error from Matcher.CompileMatchers (pkg/operators/matchers/compile.go:86). When `condition:` is set, it is looked up in the ConditionTypes map whose keys are exactly lowercase \"and\" and \"or\" (matchers.go:151-153) with NO case normalization or trimming. Any other string — including uppercase 'AND'/'OR' — fails here; an empty condition defaults to OR.","triggerScenarios":"`condition: AND` or `condition: Or` (capitalized), `condition: and-or`, `condition: \"true\"`, or a value with stray whitespace/quotes from templating.","commonSituations":"Templates written with YAML conventions favoring uppercase keys; copy-paste from docs that capitalize; unquoted YAML values carrying trailing spaces.","solutions":["Use exactly lowercase `condition: and` or `condition: or`","Omit `condition:` entirely if OR (the default) is intended","Re-validate the template: `nuclei -validate -t template.yaml`","When generating templates programmatically, emit the constant strings 'and'/'or' only"],"exampleFix":"# before\nmatchers:\n  - type: word\n    condition: AND\n    words:\n      - 'root'\n      - 'admin'\n# after\nmatchers:\n  - type: word\n    condition: and\n    words:\n      - 'root'\n      - 'admin'","handlingStrategy":"validation","validationCode":"if m.Condition != \"\" && m.Condition != \"and\" && m.Condition != \"or\" {\n\treturn fmt.Errorf(\"condition %q must be exactly 'and' or 'or' (lowercase)\", m.Condition)\n}","typeGuard":"func validCondition(c string) bool { return c == \"\" || c == \"and\" || c == \"or\" }","tryCatchPattern":"if err := m.CompileMatchers(); err != nil && strings.Contains(err.Error(), \"unknown condition specified\") {\n\t// lowercase the value and retry once, else reject template\n}","preventionTips":["Write conditions lowercase: 'and' / 'or'","Omit condition when OR default is fine","Programmatic template generators: use string constants, never user input"],"tags":["matcher","condition","yaml","template","compile-time"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}