Description

Replaces panic() calls with proper error propagation in the template loader when dialers are missing or wait group creation fails. Fixes #6674.

Changes

pkg/catalog/loader/loader.go

  • Changed LoadTemplatesWithTags signature to return ([]*templates.Template, error) instead of []*templates.Template
  • Changed LoadTemplates signature to return ([]*templates.Template, error) to match
  • Replaced panic("dialers with executionId ... not found") with return nil, fmt.Errorf(...)
  • Replaced panic("could not create wait group") with return nil, fmt.Errorf(...)
  • Moved the executionId/dialers check before the waitgroup creation to avoid unnecessary allocation on error
  • Removed unused dialers variable assignment (inlined the nil check)
  • Updated Load() to handle the error from LoadTemplates by logging it

internal/runner/lazy.go

  • Updated GetLazyAuthFetchCallback to handle the new error return from LoadTemplates

pkg/protocols/common/automaticscan/util.go

  • Updated LoadTemplatesWithTags caller to handle the new error return

pkg/catalog/loader/loader_bench_test.go

  • Updated benchmark tests to use _, _ = for the two-value return

Before

When dialers were missing or wait group creation failed, the application would panic(), causing an unrecoverable crash with no meaningful error message to the user.

After

Errors are properly propagated up the call chain. Callers can handle the error gracefully (log it, return it, etc.) instead of crashing.

Checklist

  • Replace panic with error return in LoadTemplatesWithTags
  • Propagate error through LoadTemplates
  • Update all callers to handle the new error return
  • Code compiles successfully (go build ./...)

/claim #6674

Summary by CodeRabbit

  • Bug Fixes

    • Template loading now surfaces and wraps errors instead of ignoring them; failures and validation issues are reported.
  • Refactor

    • Template loader APIs now return error values alongside results.
  • Tests

    • Benchmark tests updated to handle the loader’s new return values.

Claim

Total prize pool $200
Total paid $0
Status Pending
Submitted February 27, 2026
Last updated February 27, 2026

Contributors

A6

a638011

@a638011

100%

Sponsors

PR

ProjectDiscovery

@projectdiscovery

$100
MA

Madhavan Deepak

@Madhavan-Deepak

$100