Skip to content

fix(loader): replace panic with propagated error when dialers are missing#7030

Open
juzigu40-ui wants to merge 2 commits intoprojectdiscovery:devfrom
juzigu40-ui:codex/v100-nuclei-6674
Open

fix(loader): replace panic with propagated error when dialers are missing#7030
juzigu40-ui wants to merge 2 commits intoprojectdiscovery:devfrom
juzigu40-ui:codex/v100-nuclei-6674

Conversation

@juzigu40-ui
Copy link

@juzigu40-ui juzigu40-ui commented Feb 25, 2026

Summary

  • replace panic in LoadTemplatesWithTags when dialers are missing with a structured error return
  • replace panic on wait-group initialization failure with fmt.Errorf
  • propagate LoadTemplatesWithTags errors through automatic scan utility
  • keep LoadTemplates backward-compatible by logging and returning an empty set on load failure

Validation

  • go test ./pkg/catalog/loader ./pkg/protocols/common/automaticscan -count=1

Ref: #6674

Summary by CodeRabbit

  • Bug Fixes
    • Template loading operations now properly return errors to calling code instead of panicking when initialization failures occur.
    • Error handling in template loading workflows updated to propagate errors throughout the operation instead of silently ignoring failures.

@auto-assign auto-assign bot requested a review from Mzack9999 February 25, 2026 05:22
@neo-by-projectdiscovery-dev
Copy link

neo-by-projectdiscovery-dev bot commented Feb 25, 2026

Neo - PR Security Review

No security issues found

Highlights

  • Replaces panic with structured error returns in LoadTemplatesWithTags when dialers are missing
  • Replaces panic with fmt.Errorf when wait-group initialization fails
  • Propagates LoadTemplatesWithTags errors through automatic scan utility
  • Maintains backward compatibility in LoadTemplates by logging errors and returning empty set

Comment @neo help for available commands. · Open in Neo

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d771daa and 05a320a.

📒 Files selected for processing (2)
  • pkg/catalog/loader/loader.go
  • pkg/protocols/common/automaticscan/util.go

Walkthrough

This change introduces error propagation to template loading functions. LoadTemplatesWithTags now returns an error alongside templates, replacing panic-based error handling with explicit error returns. Callers updated to handle these errors appropriately via error checks and logging.

Changes

Cohort / File(s) Summary
Template Loading Error Handling
pkg/catalog/loader/loader.go
LoadTemplatesWithTags signature changed to return ([]*templates.Template, error). LoadTemplates now captures and logs errors from LoadTemplatesWithTags before returning nil. Internal wait-group and dialer lookup failures converted from panics to error returns.
Error Propagation in Caller
pkg/protocols/common/automaticscan/util.go
LoadTemplatesWithTags call updated to capture returned error. Early return added when error is non-nil; remaining logic (empty checks, clustering, logging) proceeds only on success.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

🐰 Templates now gracefully fail,
No more panics—just a trail
Of errors caught and gently passed,
From here to there, a safer path at last!
Our code hops forward, error-aware,
Through bunny-tested code with care. 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing panic with error propagation when dialers are missing, which is the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants