Replace both panic() calls in LoadTemplatesWithTags with proper error returns using fmt.Errorf, and update all callers to handle errors gracefully.
Core loader (pkg/catalog/loader/loader.go):
LoadTemplatesWithTags() now returns ([]*templates.Template, error) instead of panickingLoadTemplates() signature updated to ([]*templates.Template, error)Load() signature updated to return errorCallers updated:
internal/runner/runner.go — store.Load() error checkedinternal/runner/lazy.go — LoadTemplates() error propagated; fixed variable shadowingcmd/integration-test/library.go — store.Load() error checkedinternal/server/nuclei_sdk.go — store.Load() error checkedlib/sdk.go — store.Load() error checkedlib/multi.go — store.Load() error checkedpkg/protocols/common/automaticscan/util.go — LoadTemplatesWithTags() error propagatedTests:
pkg/catalog/loader/loader_bench_test.go — updated for two-value returnsBuild and all tests pass:
$ go build ./...
# clean build, no errors
$ go test ./pkg/catalog/loader/...
ok github.com/projectdiscovery/nuclei/v3/pkg/catalog/loader 0.976s
$ go test ./pkg/protocols/common/automaticscan/...
ok github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/automaticscan 0.796s
$ go test ./internal/runner/...
ok github.com/projectdiscovery/nuclei/v3/internal/runner 1.116s
$ go test ./lib/...
ok github.com/projectdiscovery/nuclei/v3/lib 39.180s
ok github.com/projectdiscovery/nuclei/v3/lib/tests 36.628s
dev)LoadTemplatesWithTags)/claim #6674
Cristol
@manas-io-ai
ProjectDiscovery
@projectdiscovery
Madhavan Deepak
@Madhavan-Deepak