Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: gracefully handle missing config for webhooks (#7787)

Max Deichmann4fc2e3305846
diff --git a/packages/shared/src/server/automations/webhooks.ts b/packages/shared/src/server/automations/webhooks.ts
index 90d2b6b9db..08218497eb 100644
--- a/packages/shared/src/server/automations/webhooks.ts
+++ b/packages/shared/src/server/automations/webhooks.ts
@@ -48,7 +48,10 @@ export const executeWebhook = async (input: WebhookInput) => {
});
if (!automation) {
- throw new LangfuseNotFoundError(`Automation ${automationId} not found`);
+ logger.warn(
+ `Automation ${automationId} not found for project ${projectId}. We ack the job and will not retry.`,
+ );
+ return;
}
const actionConfig = await getActionByIdWithSecrets({
@@ -179,7 +182,10 @@ export const executeWebhook = async (input: WebhookInput) => {
});
if (!automation) {
- throw new LangfuseNotFoundError(`Automation ${automationId} not found`);
+ logger.warn(
+ `Automation ${automationId} not found for project ${projectId}. We ack the job and will not retry.`,
+ );
+ return;
}
const shouldRetryJob =
diff --git a/worker/src/__tests__/webhooks.test.ts b/worker/src/__tests__/webhooks.test.ts
index 9bd4b0e273..375b7b7b61 100644
--- a/worker/src/__tests__/webhooks.test.ts
+++ b/worker/src/__tests__/webhooks.test.ts
@@ -497,5 +497,34 @@ describe("Webhook Integration Tests", () => {
});
expect(trigger?.status).toBe(JobConfigState.INACTIVE);
});
+
+ it("should handle missing automation gracefully without throwing error", async () => {
+ const fullPrompt = await prisma.prompt.findUnique({
+ where: { id: promptId },
+ });
+
+ const executionId = v4();
+ const nonExistentAutomationId = v4(); // Use a random ID that doesn't exist
+
+ const webhookInput: WebhookInput = {
+ projectId,
+ automationId: nonExistentAutomationId,
+ executionId,
+ payload: {
+ prompt: PromptDomainSchema.parse(fullPrompt),
+ action: "created",
+ type: "prompt-version",
+ },
+ };
+
+ // Should not throw an error, but return gracefully
+ await expect(executeWebhook(webhookInput)).resolves.toBeUndefined();
+
+ // Verify that no execution record was created since automation doesn't exist
+ const execution = await prisma.automationExecution.findUnique({
+ where: { id: executionId },
+ });
+ expect(execution).toBeNull();
+ });
});
});