Summary
This PR fixes Issue #6674 by replacing panic statements with proper error handling in the template loader when dialers are missing for a given execution ID.
Changes
Core Fix (pkg/catalog/loader/loader.go)
- Replaced
panic("dialers with executionId ... not found") with return nil, fmt.Errorf("dialers with executionId %s not found", ...)
- Updated
LoadTemplatesWithTags() and LoadTemplates() function signatures to return error
- Also fixed wait group creation panic to return proper error
Callers Updated
- internal/runner/lazy.go: Lazy auth template loading now properly handles the error and wraps it with context
- pkg/protocols/common/automaticscan/util.go: Automatic tech detection template loading propagates errors correctly
- pkg/catalog/loader/loader_bench_test.go: Updated benchmark tests to handle new error return values
Testing
- All existing tests pass
- Build verification successful (
go build ./...)
- Test verification successful (
go test ./pkg/catalog/loader/... ./internal/runner/... ./pkg/protocols/common/automaticscan/...)
Impact
This change enables graceful error handling instead of hard panics, allowing callers to handle the error condition appropriately. The Load() method uses logger.Fatal() for backward compatibility while providing a clear error message.
Closes #6674
/claim #6674
Summary by CodeRabbit
Release Notes
- Bug Fixes
- Improved error handling and propagation for template loading operations, ensuring failures are properly captured and reported rather than silently ignored.
- Enhanced error messages to provide clearer context when template-related issues occur.
- Increased reliability by enforcing template validation constraints.