Skip to content

Reject webhook/schedule flows on prediction API and surface trigger-specific code samples#6361

Open
HenryHengZJ wants to merge 2 commits intomainfrom
feat/start-input-type-trigger-guard
Open

Reject webhook/schedule flows on prediction API and surface trigger-specific code samples#6361
HenryHengZJ wants to merge 2 commits intomainfrom
feat/start-input-type-trigger-guard

Conversation

@HenryHengZJ
Copy link
Copy Markdown
Contributor

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.

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 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.

Comment on lines +1605 to +1610
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.`
)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.`
            )
        }

Comment thread packages/server/src/utils/buildAgentflow.ts
…ntFlow function to include the configured HTTP method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant