Skip to content

fix: clarify webhook debug endpoint behavior#33597

Merged
laipz8200 merged 2 commits intomainfrom
webhook-debug-conflict
Mar 18, 2026
Merged

fix: clarify webhook debug endpoint behavior#33597
laipz8200 merged 2 commits intomainfrom
webhook-debug-conflict

Conversation

@laipz8200
Copy link
Copy Markdown
Member

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #33595

Return an explicit conflict response when the webhook debug URL is called without an active debug listener, and include the published execution URL so callers can use the correct endpoint for workflow execution.

This prevents a misleading success response when the request cannot produce a workflow run.

Screenshots

Before After
N/A N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@laipz8200 laipz8200 self-assigned this Mar 17, 2026
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 17, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the webhook debug endpoint's behavior by providing a clear error response when a debug call is made without an active Variable Inspector listener. Previously, such calls might have resulted in a misleading success response despite no workflow execution. The change now returns a 409 Conflict status with an informative message and the correct execution URL, improving user experience and preventing confusion about the debug endpoint's purpose.

Highlights

  • Improved Webhook Debug Endpoint Behavior: Introduced an explicit 409 Conflict response for the webhook debug endpoint when no active debug listener is present, preventing misleading success responses.
  • Guidance for Workflow Execution: Included the published workflow's execution URL in the error response to guide users to the correct endpoint for actual workflow execution.
  • Enhanced Documentation: Updated the docstring for the handle_webhook_debug function to provide clearer documentation on its intended behavior and the rationale behind the new error handling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • api/controllers/trigger/webhook.py
    • Expanded the docstring for handle_webhook_debug to detail its debug-only nature and the rationale for the new error handling.
    • Added a conditional check after TriggerDebugEventBus.dispatch to detect when no listeners are active.
    • Implemented a jsonify response with a 409 status code, an error message, and the execution_url if no listener is found.
    • Logged a warning when a debug request is dropped without an active listener.
  • api/tests/unit_tests/controllers/trigger/test_webhook.py
    • Added webhook_url attribute to DummyWebhookTrigger for testing purposes.
    • Created test_debug_requires_active_listener to assert the correct 409 response and error message when dispatch returns 0.
    • Updated test_debug_success to explicitly mock TriggerDebugEventBus.dispatch to return 1, ensuring the success path is tested correctly.
Activity
  • The pull request was created by laipz8200.
  • No further human activity (comments, reviews, or progress updates) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-17 13:07:36.663862004 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-17 13:07:27.715841781 +0000
@@ -2200,17 +2200,21 @@
 ERROR `SimpleNamespace` is not assignable to attribute `request` with type `Request` [bad-assignment]
   --> tests/unit_tests/controllers/trigger/test_webhook.py:12:22
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:72:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:73:16
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:83:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:84:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:100:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:101:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:124:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:122:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:135:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:123:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:152:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:146:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:157:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:174:16
 ERROR Object of class `ModuleType` has no attribute `web_ns` [missing-attribute]
   --> tests/unit_tests/controllers/web/test_message_list.py:41:9
 ERROR Object of class `ModuleType` has no attribute `WebApiResource` [missing-attribute]

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-17 13:07:36.663862004 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-17 13:07:27.715841781 +0000
@@ -2200,17 +2200,21 @@
 ERROR `SimpleNamespace` is not assignable to attribute `request` with type `Request` [bad-assignment]
   --> tests/unit_tests/controllers/trigger/test_webhook.py:12:22
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:72:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:73:16
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:83:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:84:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:100:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:101:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:124:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:122:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:135:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:123:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:152:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:146:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:157:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:174:16
 ERROR Object of class `ModuleType` has no attribute `web_ns` [missing-attribute]
   --> tests/unit_tests/controllers/web/test_message_list.py:41:9
 ERROR Object of class `ModuleType` has no attribute `WebApiResource` [missing-attribute]

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the webhook debug endpoint by returning a 409 Conflict response when no debug listener is active, which is a great clarification of its behavior. The changes are well-implemented and include a new test case to cover this scenario. I have one suggestion to make the new test even more robust.

@laipz8200 laipz8200 changed the title Clarify webhook debug endpoint behavior fix: clarify webhook debug endpoint behavior Mar 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-17 13:12:45.478621402 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-17 13:12:36.782508218 +0000
@@ -2200,17 +2200,23 @@
 ERROR `SimpleNamespace` is not assignable to attribute `request` with type `Request` [bad-assignment]
   --> tests/unit_tests/controllers/trigger/test_webhook.py:12:22
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:72:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:73:16
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:83:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:84:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:100:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:101:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:124:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:122:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:135:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:123:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:152:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:127:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:150:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:161:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:178:16
 ERROR Object of class `ModuleType` has no attribute `web_ns` [missing-attribute]
   --> tests/unit_tests/controllers/web/test_message_list.py:41:9
 ERROR Object of class `ModuleType` has no attribute `WebApiResource` [missing-attribute]

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-17 13:12:45.478621402 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-17 13:12:36.782508218 +0000
@@ -2200,17 +2200,23 @@
 ERROR `SimpleNamespace` is not assignable to attribute `request` with type `Request` [bad-assignment]
   --> tests/unit_tests/controllers/trigger/test_webhook.py:12:22
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:72:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:73:16
 ERROR Cannot index into `Response` [bad-index]
-  --> tests/unit_tests/controllers/trigger/test_webhook.py:83:16
+  --> tests/unit_tests/controllers/trigger/test_webhook.py:84:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:100:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:101:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:124:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:122:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:135:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:123:16
 ERROR Cannot index into `Response` [bad-index]
-   --> tests/unit_tests/controllers/trigger/test_webhook.py:152:16
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:127:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:150:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:161:16
+ERROR Cannot index into `Response` [bad-index]
+   --> tests/unit_tests/controllers/trigger/test_webhook.py:178:16
 ERROR Object of class `ModuleType` has no attribute `web_ns` [missing-attribute]
   --> tests/unit_tests/controllers/web/test_message_list.py:41:9
 ERROR Object of class `ModuleType` has no attribute `WebApiResource` [missing-attribute]

Copy link
Copy Markdown
Contributor

@hjlarry hjlarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 18, 2026
@laipz8200 laipz8200 merged commit 116cc22 into main Mar 18, 2026
17 checks passed
@laipz8200 laipz8200 deleted the webhook-debug-conflict branch March 18, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook debug URL returns success without starting the published workflow

2 participants