Skip to content

Commit

Permalink
Validate trigger event ID before execution (#14314)
Browse files Browse the repository at this point in the history
* Validate trigger event ID before execution

* Fix the trigger mock
  • Loading branch information
DeividasK authored Sep 3, 2024
1 parent e47a681 commit 8fa3ebe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/cyan-spies-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal validate capability trigger event ID before executing
6 changes: 6 additions & 0 deletions core/services/workflows/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/jonboulle/clockwork"

"github.com/smartcontractkit/chainlink-common/pkg/workflows/exec"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
Expand Down Expand Up @@ -418,6 +419,11 @@ func (e *Engine) loop(ctx context.Context) {

te := resp.Event

if te.ID == "" {
e.logger.With(tIDKey, te.TriggerType).Error("trigger event ID is empty; not executing")
continue
}

executionID, err := generateExecutionID(e.workflow.id, te.ID)
if err != nil {
e.logger.With(tIDKey, te.ID).Errorf("could not generate execution ID: %v", err)
Expand Down
4 changes: 3 additions & 1 deletion core/services/workflows/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ func mockTrigger(t *testing.T) (capabilities.TriggerCapability, capabilities.Tri
require.NoError(t, err)
tr := capabilities.TriggerResponse{
Event: capabilities.TriggerEvent{
Outputs: resp,
TriggerType: mt.ID,
ID: time.Now().UTC().Format(time.RFC3339),
Outputs: resp,
},
}
mt.triggerEvent = &tr
Expand Down

0 comments on commit 8fa3ebe

Please sign in to comment.