-
Notifications
You must be signed in to change notification settings - Fork 354
Closed
Labels
Description
Describe the bug
genkit.LookupPlugin
will panic if a plugin does not exist due to a type-assertion on a nil
value:
panic: interface conversion: interface is nil, not genkit.Plugin
If this is expected behaviour, how should we be ascertaining if a plugin exists before registering? Since registering a plugin twice will (in some cases) also result in a panic.
To Reproduce
g, _ := genkit.Init(context.Background())
fooPlugin := genkit.LookupPlugin(g, "foo") // LookupPlugin should return nil, but panics instead
if fooPlugin == nil {
fmt.Println("'foo' does not exist")
return
}
fmt.Println("'foo' exists", fooPlugin.Name())
Expected behavior
A clear and concise description of what you expected to happen.
Relevant Code Snippet
Lines 764 to 771 in d7080f4
// LookupPlugin retrieves a registered plugin instance by its name. | |
// Plugins are registered during initialization via [WithPlugins]. | |
// It returns the plugin instance as `Plugin` if found, or `nil` otherwise. | |
// The caller is responsible for type-asserting the returned value to the | |
// specific plugin type. | |
func LookupPlugin(g *Genkit, name string) Plugin { | |
return g.reg.LookupPlugin(name).(Plugin) | |
} |
Runtime (please complete the following information):
- OS: darwin/arm64
Go version
- Genkit
v0.6.2
- Go
v1.24.2
Additional context
N/A
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done