projectdiscovery/nuclei · error

unknown condition specified: %s

Error message

unknown condition specified: %s

What it means

A workflow matcher's condition string could not be resolved. workflows.Matcher.Compile maps matcher.Condition to a ConditionType using the ConditionTypes table, which only contains "and" and "or"; anything else — including casing variants like "AND" or "And" — fails compilation with this error.

Source

Thrown at pkg/workflows/workflows.go:92

	// ANDCondition matches responses with AND condition in arguments.
	ANDCondition ConditionType = iota + 1
	// ORCondition matches responses with AND condition in arguments.
	ORCondition
)

// ConditionTypes is a table for conversion of condition type from string.
var ConditionTypes = map[string]ConditionType{
	"and": ANDCondition,
	"or":  ORCondition,
}

// Compile compiles the matcher for workflow
func (matcher *Matcher) Compile() error {
	var ok bool
	if matcher.Condition != "" {
		matcher.condition, ok = ConditionTypes[matcher.Condition]
		if !ok {
			return fmt.Errorf("unknown condition specified: %s", matcher.Condition)
		}
	} else {
		matcher.condition = ORCondition
	}
	return nil
}

// Match matches a name for matcher names or name
func (matcher *Matcher) Match(result *operators.Result) bool {
	names := matcher.Name.ToSlice()
	if len(names) == 0 {
		return false
	}

	for i, name := range names {
		matchOK := result.HasMatch(name)
		extractOK := result.HasExtract(name)

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Set matchers[].condition to exactly "and" or "or" (lowercase).
  2. Omit the condition entirely when OR semantics are intended — Compile defaults to ORCondition when Condition is empty.
  3. Validate the workflow template against the nuclei template schema (make template-validate) before running.

Example fix

# before
matchers:
  - name: a
    condition: AND   # -> unknown condition specified: AND

# after
matchers:
  - name: a
    condition: and
Defensive patterns

Strategy: type-guard

Validate before calling

var validConditions = map[string]bool{"and": true, "or": true}
for _, m := range wf.Matchers {
    if m.Condition != "" && !validConditions[m.Condition] {
        return fmt.Errorf("matcher %q: condition must be \"and\" or \"or\"", m.Name)
    }
}

Type guard

func isValidWorkflowCondition(s string) bool {
    _, ok := workflows.ConditionTypes[s]
    return s == "" || ok
}

Try / catch

if err := matcher.Compile(); err != nil {
    if strings.Contains(err.Error(), "unknown condition") { /* fix template YAML, lowercase and/or drop */ }
}

Prevention

When it happens

Trigger: A workflow YAML with matchers[].condition set to a value other than exactly "and" or "or" (e.g. "AND", "all", "none", "&&"), or a typo like "adr".

Common situations: Hand-edited workflow templates; porting workflows from other YAML dialects where conditions are written differently; uppercase normalization assumptions — the lookup is case-sensitive.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/e1bb3512f2a15734. Report an issue: GitHub.