Skip to content

Commit fac2f8a

Browse files
fix: include webhook_reply and cron_cursor_job_id in version hash
The version hash calculation in WorkflowVersions.generate_hash/1 did not include the webhook_reply or cron_cursor_job_id trigger fields. This meant that changes to these fields were not detected by CLI deploy or sandbox merge, since the hash remained unchanged. Add both fields to the trigger_keys list used in hash generation, and add tests verifying that changing either field produces a different hash. Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
1 parent 8cad436 commit fac2f8a

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ and this project adheres to
2121

2222
### Fixed
2323

24+
- Include `webhook_reply` and `cron_cursor_job_id` in the workflow version hash
25+
so that changes to these trigger fields are properly detected by CLI deploy and
26+
sandbox merge
27+
[#4596](https://github.com/OpenFn/lightning/issues/4596)
28+
2429
## [2.16.1-pre1] - 2026-04-04
2530

2631
### Added

lib/lightning/workflow_versions.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,13 @@ defmodule Lightning.WorkflowVersions do
246246
:body
247247
]
248248

249-
trigger_keys = [:type, :cron_expression, :enabled]
249+
trigger_keys = [
250+
:type,
251+
:cron_expression,
252+
:enabled,
253+
:webhook_reply,
254+
:cron_cursor_job_id
255+
]
250256

251257
edge_keys = [
252258
:name,

test/lightning/workflow_versions_test.exs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,57 @@ defmodule Lightning.WorkflowVersionsTest do
493493
refute hash1 == hash2
494494
end
495495

496+
test "hash changes when webhook_reply changes" do
497+
workflow = insert(:workflow, name: "Test")
498+
499+
trigger =
500+
insert(:trigger,
501+
workflow: workflow,
502+
type: :webhook,
503+
webhook_reply: :before_start
504+
)
505+
506+
workflow = Repo.preload(workflow, [:triggers, :jobs, :edges])
507+
hash1 = WorkflowVersions.generate_hash(workflow)
508+
509+
trigger
510+
|> Ecto.Changeset.change(webhook_reply: :after_completion)
511+
|> Repo.update!()
512+
513+
workflow = Repo.preload(workflow, [:triggers, :jobs, :edges], force: true)
514+
hash2 = WorkflowVersions.generate_hash(workflow)
515+
516+
refute hash1 == hash2
517+
end
518+
519+
test "hash changes when cron_cursor_job_id changes" do
520+
workflow = insert(:workflow, name: "Test")
521+
job1 = insert(:job, workflow: workflow, name: "Job A")
522+
job2 = insert(:job, workflow: workflow, name: "Job B")
523+
524+
insert(:trigger,
525+
workflow: workflow,
526+
type: :cron,
527+
cron_expression: "0 * * * *",
528+
cron_cursor_job: job1
529+
)
530+
531+
workflow = Repo.preload(workflow, [:triggers, :jobs, :edges])
532+
hash1 = WorkflowVersions.generate_hash(workflow)
533+
534+
# Change the cron cursor job
535+
[trigger] = workflow.triggers
536+
537+
trigger
538+
|> Ecto.Changeset.change(cron_cursor_job_id: job2.id)
539+
|> Repo.update!()
540+
541+
workflow = Repo.preload(workflow, [:triggers, :jobs, :edges], force: true)
542+
hash2 = WorkflowVersions.generate_hash(workflow)
543+
544+
refute hash1 == hash2
545+
end
546+
496547
test "properly orders triggers by type" do
497548
workflow = insert(:workflow, name: "Test")
498549

0 commit comments

Comments
 (0)