{"record":{"id":"710590f38483209c","repo":"projectdiscovery/katana","slug":"unsupported-strategy","errorCode":null,"errorMessage":"unsupported strategy","messagePattern":"unsupported strategy","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/utils/queue/queue.go","lineNumber":32,"sourceCode":"// basis the bucket is distributed.  Lower scores are picked up first, and\n// higher scores which have a greater chance of being just random\n// noise are picked up later in depth first.\n//\n// Depth-first queue uses a simple stack for LIFO operations and distributes\n// items as they come in.\ntype Queue struct {\n\tsync.Mutex\n\tTimeout       time.Duration\n\tStrategy      Strategy\n\tstack         *stack\n\tpriorityQueue *priorityQueue\n}\n\n// New creates a new queue from the type specified.\nfunc New(strategyName string, timeout int) (*Queue, error) {\n\tstrategy, ok := strategiesMap[strategyName]\n\tif !ok {\n\t\treturn nil, errors.New(\"unsupported strategy\")\n\t}\n\n\tqueue := &Queue{\n\t\tStrategy:      strategy,\n\t\tTimeout:       time.Duration(timeout) * time.Second,\n\t\tstack:         newStack(),\n\t\tpriorityQueue: newPriorityQueue(),\n\t}\n\n\treturn queue, nil\n}\n\n// Len returns the number of items in queue.\nfunc (q *Queue) Len() int {\n\tq.Lock()\n\tdefer q.Unlock()\n\n\tswitch q.Strategy {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/utils/queue/queue.go#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the strategiesMap keys in pkg/utils/queue/queue.go and use exactly one of the supported names.","Fix casing/typos in the strategy string coming from config or environment.","Validate the strategy name at config-load time and fail fast with a clear message listing valid values.","Pin the library version and re-check the strategy names after upgrades.","Default to a known-good strategy ('memory' or 'disk') when the configured value is invalid."],"exampleFix":"// before\nq, err := queue.New(cfg.QueueStrategy, 30) // cfg value: \"memry\"\n// after\nif _, ok := validStrategies[cfg.QueueStrategy]; !ok {\n    log.Fatalf(\"invalid queue strategy %q; valid: memory, disk\", cfg.QueueStrategy)\n}\nq, err := queue.New(cfg.QueueStrategy, 30)","handlingStrategy":"validation","validationCode":"var validStrategies = map[string]struct{}{\"memory\": {}, \"disk\": {}} // align with strategiesMap\nif _, ok := validStrategies[strategyName]; !ok {\n    return fmt.Errorf(\"invalid queue strategy %q\", strategyName)\n}\nq, err := queue.New(strategyName, timeout)","typeGuard":null,"tryCatchPattern":"q, err := queue.New(strategyName, timeout)\nif err != nil {\n    if err.Error() == \"unsupported strategy\" {\n        q, err = queue.New(\"memory\", timeout) // safe fallback\n    }\n    if err != nil { return err }\n}","preventionTips":["Keep the strategy name in one constant/config field, never inline strings","Validate config at startup with a clear list of valid strategies","Re-check strategy names after library upgrades"],"tags":["queue","configuration","strategy","go"],"backgroundTag":"unsupported-config-value","analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}