Replaces two panic() calls in LoadTemplatesWithTags (pkg/catalog/loader/loader.go, lines ~714 and ~722) with proper error returns using fmt.Errorf, allowing callers to handle failures gracefully instead of crashing.
/claim #6674
| File | Change |
|---|---|
pkg/catalog/loader/loader.go |
LoadTemplatesWithTags returns ([]*templates.Template, error); LoadTemplates returns ([]*templates.Template, error); Load() returns error; both panic() calls replaced with return nil, fmt.Errorf(...) |
internal/runner/runner.go |
Load() error check added |
internal/runner/lazy.go |
LoadTemplates error handling added |
internal/server/nuclei_sdk.go |
Load() error check added |
lib/sdk.go |
Load() error check added |
lib/multi.go |
Load() error check added |
cmd/integration-test/library.go |
Load() error check added |
pkg/protocols/common/automaticscan/util.go |
LoadTemplatesWithTags error handling added |
pkg/catalog/loader/loader_bench_test.go |
Updated to handle (_, error) return |
The current code panics when:
syncutil.New() fails to create a wait groupprotocolstate.GetDialersWithId() returns nil (dialers not initialized)This is too harsh for a public API that may be exercised in non-scanning flows. The broader codebase pattern returns fmt.Errorf when encountering missing resources rather than panicking.
errors.Wrap, errkit.Wrapf, fmt.Errorf)dev branchfmt.Errorf messagesFixes #6674
🤖 Built with AI assistance (Claude) Co-Authored-By: Claude noreply@anthropic.com
Bug Fixes
Refactor
Tests
St34lthcole
@St34lthcole
ProjectDiscovery
@projectdiscovery
Madhavan Deepak
@Madhavan-Deepak