From a5d599fb9a09d32c2b023984462fc5c147272630 Mon Sep 17 00:00:00 2001 From: Richard McDaniel Date: Mon, 27 Oct 2025 04:03:10 +0000 Subject: [PATCH] Fix webhook URL generation to include workflow slug The Activity::webhookUrl() method was generating URLs that didn't match the route pattern registered by Webhooks::registerSignalWebhooks(), causing 404 errors when external services called the webhooks. - Added workflow slug to signal webhook URL generation - Updated test to expect the correct URL format with workflow slug Resolves issue where signal webhooks were failing due to URL mismatch. --- src/Activity.php | 6 ++++-- tests/Unit/ActivityTest.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Activity.php b/src/Activity.php index 7c966b0b..c1cb017c 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -77,12 +77,14 @@ public function workflowId() public function webhookUrl(string $signalMethod = ''): string { $basePath = config('workflows.webhooks_route', '/webhooks'); + $workflow = Str::kebab(class_basename($this->storedWorkflow->class)); + if ($signalMethod === '') { - $workflow = Str::kebab(class_basename($this->storedWorkflow->class)); return url("{$basePath}/{$workflow}"); } + $signal = Str::kebab($signalMethod); - return url("{$basePath}/signal/{$this->storedWorkflow->id}/{$signal}"); + return url("{$basePath}/signal/{$workflow}/{$this->storedWorkflow->id}/{$signal}"); } public function handle() diff --git a/tests/Unit/ActivityTest.php b/tests/Unit/ActivityTest.php index 7e1b8ff8..42609927 100644 --- a/tests/Unit/ActivityTest.php +++ b/tests/Unit/ActivityTest.php @@ -131,6 +131,6 @@ public function testWebhookUrl(): void ]); $this->assertSame('http://localhost/webhooks/test-workflow', $activity->webhookUrl()); - $this->assertSame('http://localhost/webhooks/signal/1/other', $activity->webhookUrl('other')); + $this->assertSame('http://localhost/webhooks/signal/test-workflow/1/other', $activity->webhookUrl('other')); } }