Description
The template loader in pkg/catalog/loader/loader.go (around lines 684-703) currently panics when protocolstate.GetDialersWithId() returns nil. This is too harsh for a public API that may be exercised in non-scanning flows.
Current Behavior
When dialers are not initialized, the code panics:
dialers := protocolstate.GetDialersWithId(typesOpts.ExecutionId)
if dialers == nil {
panic("dialers with executionId " + typesOpts.ExecutionId + " not found")
}
Expected Behavior
The loader should return a proper error instead of panicking, allowing callers to handle the situation gracefully. The broader codebase pattern returns fmt.Errorf when dialers are missing rather than panicking.
Suggested Changes
- Replace the panic with proper error return (e.g.,
return fmt.Errorf("dialers with executionId %s not found", typesOpts.ExecutionId))
- Update the loader function signature to propagate the error
- Update callers to handle the error appropriately
- Add documentation noting the new error condition
Context
Callers like lazy auth template loading (internal/runner/lazy.go) and automatic tech detection (pkg/protocols/common/automaticscan/) invoke LoadTemplates/LoadTemplatesWithTags without guaranteed dialer initialization.
References
Description
The template loader in
pkg/catalog/loader/loader.go(around lines 684-703) currently panics whenprotocolstate.GetDialersWithId()returns nil. This is too harsh for a public API that may be exercised in non-scanning flows.Current Behavior
When dialers are not initialized, the code panics:
Expected Behavior
The loader should return a proper error instead of panicking, allowing callers to handle the situation gracefully. The broader codebase pattern returns
fmt.Errorfwhen dialers are missing rather than panicking.Suggested Changes
return fmt.Errorf("dialers with executionId %s not found", typesOpts.ExecutionId))Context
Callers like lazy auth template loading (
internal/runner/lazy.go) and automatic tech detection (pkg/protocols/common/automaticscan/) invokeLoadTemplates/LoadTemplatesWithTagswithout guaranteed dialer initialization.References