Reject webhook/schedule flows on prediction API and surface trigger-specific code samples#6361
Reject webhook/schedule flows on prediction API and surface trigger-specific code samples#6361HenryHengZJ wants to merge 2 commits intomainfrom
Conversation
…ce trigger-specific API snippets
There was a problem hiding this comment.
Code Review
This pull request introduces a unified StartInputType and implements validation logic to prevent prediction API calls for flows configured as Webhook or Scheduled triggers. It also updates the UI's API Code Dialog to provide specific instructions and code snippets for Webhook flows while displaying warnings for Scheduled flows. Feedback focuses on improving the accuracy and consistency of the server-side error messages, specifically by dynamically reflecting the configured HTTP method for Webhook triggers and aligning the suggested alternatives for Scheduled triggers with the UI.
| if (startInputType === 'webhookTrigger' && chatType !== ChatType.WEBHOOK) { | ||
| throw new InternalFlowiseError( | ||
| StatusCodes.BAD_REQUEST, | ||
| `This flow is configured as a Webhook Trigger. Call POST /api/v1/webhook/${chatflowid} instead of the prediction API.` | ||
| ) | ||
| } |
There was a problem hiding this comment.
The error message for Webhook Trigger flows should reflect the actual HTTP method configured in the Start node (e.g., GET, PUT) rather than hardcoding POST. This provides more accurate guidance to the user when they attempt to call the prediction API on a flow that requires a specific webhook method.
if (startInputType === 'webhookTrigger' && chatType !== ChatType.WEBHOOK) {
const webhookMethod = (startNode?.data?.inputs?.webhookMethod || 'POST').toUpperCase()
throw new InternalFlowiseError(
StatusCodes.BAD_REQUEST,
`This flow is configured as a Webhook Trigger. Call ${webhookMethod} /api/v1/webhook/${chatflowid} instead of the prediction API.`
)
}…ntFlow function to include the configured HTTP method
Calling the prediction API on a webhook flow used to silently execute with empty $webhook.* refs and skip signature/method/Content-Type checks. Schedule flows would similarly run as misconfigured chat calls. The guard makes the misconfiguration explicit, and the dialog now shows users the correct way to invoke each trigger type.