projectdiscovery/katana · error

unsupported strategy

Error message

unsupported strategy

What it means

queue.New in pkg/utils/queue/queue.go returns this when the given strategyName is not a key in strategiesMap. The queue package supports a fixed set of storage strategies; any unknown name fails construction immediately instead of defaulting.

Source

Thrown at pkg/utils/queue/queue.go:32

// basis the bucket is distributed.  Lower scores are picked up first, and
// higher scores which have a greater chance of being just random
// noise are picked up later in depth first.
//
// Depth-first queue uses a simple stack for LIFO operations and distributes
// items as they come in.
type Queue struct {
	sync.Mutex
	Timeout       time.Duration
	Strategy      Strategy
	stack         *stack
	priorityQueue *priorityQueue
}

// New creates a new queue from the type specified.
func New(strategyName string, timeout int) (*Queue, error) {
	strategy, ok := strategiesMap[strategyName]
	if !ok {
		return nil, errors.New("unsupported strategy")
	}

	queue := &Queue{
		Strategy:      strategy,
		Timeout:       time.Duration(timeout) * time.Second,
		stack:         newStack(),
		priorityQueue: newPriorityQueue(),
	}

	return queue, nil
}

// Len returns the number of items in queue.
func (q *Queue) Len() int {
	q.Lock()
	defer q.Unlock()

	switch q.Strategy {

View on GitHub (pinned to e3e742739c)

Solutions

  1. Check the strategiesMap keys in pkg/utils/queue/queue.go and use exactly one of the supported names.
  2. Fix casing/typos in the strategy string coming from config or environment.
  3. Validate the strategy name at config-load time and fail fast with a clear message listing valid values.
  4. Pin the library version and re-check the strategy names after upgrades.
  5. Default to a known-good strategy ('memory' or 'disk') when the configured value is invalid.

Example fix

// before
q, err := queue.New(cfg.QueueStrategy, 30) // cfg value: "memry"
// after
if _, ok := validStrategies[cfg.QueueStrategy]; !ok {
    log.Fatalf("invalid queue strategy %q; valid: memory, disk", cfg.QueueStrategy)
}
q, err := queue.New(cfg.QueueStrategy, 30)
Defensive patterns

Strategy: validation

Validate before calling

var validStrategies = map[string]struct{}{"memory": {}, "disk": {}} // align with strategiesMap
if _, ok := validStrategies[strategyName]; !ok {
    return fmt.Errorf("invalid queue strategy %q", strategyName)
}
q, err := queue.New(strategyName, timeout)

Try / catch

q, err := queue.New(strategyName, timeout)
if err != nil {
    if err.Error() == "unsupported strategy" {
        q, err = queue.New("memory", timeout) // safe fallback
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: Calling queue.New(strategyName, timeout) with a strategy name not registered in strategiesMap — a typo, wrong casing, or a strategy type removed/renamed between library versions.

Common situations: Passing a config value (e.g. from YAML/env) for the queue strategy with a typo like 'memoery' or 'disk-x'; upgrading the library where a strategy was renamed; hardcoding a strategy string copied from another project.

Related errors


AI-assisted analysis of projectdiscovery/katana@e3e742739c (2026-09-03). Data as JSON: /api/errors/710590f38483209c. Report an issue: GitHub.