Fix trigger loading on workflow execution
Triggers are now loaded directly from store and without access control
This commit is contained in:
@@ -616,12 +616,24 @@ func (svc *trigger) unregisterTriggers(tt ...*types.Trigger) {
|
||||
}
|
||||
}
|
||||
|
||||
func loadTrigger(ctx context.Context, s store.Storer, workflowID uint64) (res *types.Trigger, err error) {
|
||||
func loadTrigger(ctx context.Context, s store.Storer, triggerID uint64) (res *types.Trigger, err error) {
|
||||
if triggerID == 0 {
|
||||
return nil, TriggerErrInvalidID()
|
||||
}
|
||||
|
||||
if res, err = store.LookupAutomationTriggerByID(ctx, s, triggerID); errors.IsNotFound(err) {
|
||||
return nil, TriggerErrNotFound()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func loadWorkflowTriggers(ctx context.Context, s store.Storer, workflowID uint64) (tt types.TriggerSet, err error) {
|
||||
if workflowID == 0 {
|
||||
return nil, TriggerErrInvalidID()
|
||||
}
|
||||
|
||||
if res, err = store.LookupAutomationTriggerByID(ctx, s, workflowID); errors.IsNotFound(err) {
|
||||
if tt, _, err = store.SearchAutomationTriggers(ctx, s, types.TriggerFilter{WorkflowID: []uint64{workflowID}}); errors.IsNotFound(err) {
|
||||
return nil, TriggerErrNotFound()
|
||||
}
|
||||
|
||||
|
||||
@@ -521,7 +521,9 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
|
||||
// Find the trigger.
|
||||
t, err = func() (*types.Trigger, error) {
|
||||
var tt types.TriggerSet
|
||||
tt, _, err = svc.triggers.Search(ctx, types.TriggerFilter{WorkflowID: []uint64{workflowID}})
|
||||
// Load triggers directly from the store. At this point we do not care
|
||||
// about trigger search or read permissions
|
||||
tt, err = loadWorkflowTriggers(ctx, svc.store, workflowID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -539,6 +541,10 @@ func (svc *workflow) Exec(ctx context.Context, workflowID uint64, p types.Workfl
|
||||
return nil, nil
|
||||
}()
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Start with workflow scope
|
||||
scope := wf.Scope.MustMerge()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user