projectdiscovery/nuclei · error

unknown extractor type specified: %s

Error message

unknown extractor type specified: %s

What it means

Template compilation error from Extractor.CompileExtractors (pkg/operators/extractors/compile.go:19). The extractor's `type:` string is mapped via toExtractorTypes, which normalizes (trim+lowercase) and compares against the closed set {regex, kval, xpath, json, dsl}. Anything else — including an omitted `type:` (zero-value String() is "") — returns this error and the template fails to compile.

Source

Thrown at pkg/operators/extractors/compile.go:19

package extractors

import (
	"fmt"
	"regexp"
	"strings"

	"github.com/itchyny/gojq"
	"github.com/projectdiscovery/govaluate"
	"github.com/projectdiscovery/nuclei/v3/pkg/operators/cache"
	"github.com/projectdiscovery/nuclei/v3/pkg/operators/common/dsl"
)

// CompileExtractors performs the initial setup operation on an extractor
func (e *Extractor) CompileExtractors() error {
	// Set up the extractor type
	computedType, err := toExtractorTypes(e.GetType().String())
	if err != nil {
		return fmt.Errorf("unknown extractor type specified: %s", e.Type)
	}
	e.extractorType = computedType

	if e.extractorType == RegexExtractor && e.RegexGroup < 0 {
		return fmt.Errorf("regex extractor group must be >= 0, got %d", e.RegexGroup)
	}

	// Compile the regexes
	for _, regex := range e.Regex {
		if cached, err := cache.Regex().GetIFPresent(regex); err == nil && cached != nil {
			e.regexCompiled = append(e.regexCompiled, cached)
			continue
		}
		compiled, err := regexp.Compile(regex)
		if err != nil {
			return fmt.Errorf("could not compile regex: %s", regex)
		}
		_ = cache.Regex().Set(regex, compiled)

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Set `type:` to one of exactly: regex, kval, xpath, json, or dsl
  2. Check YAML indentation so `type:` sits directly under the extractor item
  3. Run `nuclei -validate -t template.yaml` (or `make template-validate`) to catch it before scanning
  4. If embedding via the SDK, log the failing e.Type value — the error prints the raw, un-normalized string

Example fix

# before
extractors:
  - type: JSON
    json:
      - '.token'
# after
extractors:
  - type: json
    json:
      - '.token'
Defensive patterns

Strategy: validation

Validate before calling

import (
  "strings"
  ea "github.com/projectdiscovery/nuclei/v3/pkg/operators/extractors"
)

var validExtractorTypes = map[string]bool{"regex": true, "kval": true, "xpath": true, "json": true, "dsl": true}

func extractorTypeOK(t string) bool { return validExtractorTypes[strings.ToLower(strings.TrimSpace(t))] }

Type guard

type ExtractorSpec struct{ Type string; Regex []string; JSON []string; KVal []string; DSL []string }

func (e ExtractorSpec) Valid() bool { return extractorTypeOK(e.Type) }

Try / catch

if err := ex.CompileExtractors(); err != nil {
	if strings.HasPrefix(err.Error(), "unknown extractor type") {
		// template-authoring error: reject the template with file/line context
	}
	return err
}

Prevention

When it happens

Trigger: An extractor block with `type: kval ` misspelled values like `type: json-q`, legacy names like `type: JSONQuery`, or a missing `type:` field when only regex/kval/xpath/json/dsl are accepted.

Common situations: Hand-writing templates and typo-ing the type; porting templates from other tools that use different type names; YAML indentation placing `type:` under the wrong nesting so it never unmarshals; upgrading nuclei versions where a previously informal type name is not in the enum.

Related errors


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