Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions admin/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,6 @@ func TestMergeInto_WithRealAdminConfig(t *testing.T) {
}
}

func TestLoadConfig_Parses(t *testing.T) {
cfg, err := LoadConfig()
if err != nil {
t.Fatalf("LoadConfig: %v", err)
}
if cfg == nil {
t.Fatal("expected non-nil config")
}
if len(cfg.Modules) == 0 {
t.Error("expected at least one module in admin config")
}
}

func TestLoadConfigRaw_NonEmpty(t *testing.T) {
raw, err := LoadConfigRaw()
if err != nil {
t.Fatalf("LoadConfigRaw: %v", err)
}
if len(raw) == 0 {
t.Error("expected non-empty raw config data")
}
}

func TestLoadConfig_HasExpectedModules(t *testing.T) {
cfg, err := LoadConfig()
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ func (e *StdEngine) LoadPlugin(p plugin.EnginePlugin) error {
for triggerType, factory := range p.TriggerFactories() {
// Delegate to the bridge helper; triggers are interfaces.Trigger values
// (module.Trigger is a type alias for interfaces.Trigger).
e.registerPluginTrigger(triggerType, factory)
if err := e.registerPluginTrigger(triggerType, factory); err != nil {
return fmt.Errorf("load plugin: %w", err)
}
}

// Register pipeline trigger config wrappers from plugin (optional interface).
Expand Down
12 changes: 7 additions & 5 deletions engine_module_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ func (e *StdEngine) registerPluginSteps(typeName string, stepFactory func(name s
// Lives here to avoid a direct module.Trigger type assertion in engine.go.
// Since module.Trigger is now an alias for interfaces.Trigger, the assertion
// uses the canonical interface type.
func (e *StdEngine) registerPluginTrigger(triggerType string, factory func() any) {
// Returns an error when the factory returns a value that does not satisfy
// interfaces.Trigger, so LoadPlugin can fail deterministically instead of
// silently skipping the trigger and surfacing a confusing "no handler found"
// error later at runtime.
func (e *StdEngine) registerPluginTrigger(triggerType string, factory func() any) error {
result := factory()
trigger, ok := result.(interfaces.Trigger)
if !ok {
// Fail fast with a clear warning when a plugin misconfigures its trigger factory.
// This avoids silent failures that later surface as "no handler found" errors.
e.logger.Error(fmt.Sprintf("workflow: plugin trigger factory for %q returned non-Trigger type %T; trigger not registered", triggerType, result))
return
return fmt.Errorf("workflow: plugin trigger factory for %q returned non-Trigger type %T", triggerType, result)
}
e.triggerTypeMap[triggerType] = trigger.Name()
e.RegisterTrigger(trigger)
return nil
}
2 changes: 1 addition & 1 deletion interfaces/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

// EventEmitter publishes workflow and step lifecycle events.
// EventEmitter publishes workflow lifecycle events.
// *module.WorkflowEventEmitter satisfies this interface.
// All methods must be safe to call when no event bus is configured (no-ops).
type EventEmitter interface {
Expand Down