fix(webhook-trigger): remove error handling (#24902)

This commit is contained in:
cathy 2025-09-01 17:11:49 +08:00 committed by GitHub
parent 4d0ff5c281
commit 4ae19e6dde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 30 deletions

View File

@ -6,6 +6,7 @@
*/ */
import nodeDefault from '../default' import nodeDefault from '../default'
import type { WebhookTriggerNodeType } from '../types'
// Simple mock translation function // Simple mock translation function
const mockT = (key: string, params?: any) => { const mockT = (key: string, params?: any) => {
@ -32,13 +33,11 @@ describe('Webhook Trigger Node Default', () => {
expect(Array.isArray(defaultValue.headers)).toBe(true) expect(Array.isArray(defaultValue.headers)).toBe(true)
expect(Array.isArray(defaultValue.params)).toBe(true) expect(Array.isArray(defaultValue.params)).toBe(true)
expect(Array.isArray(defaultValue.body)).toBe(true) expect(Array.isArray(defaultValue.body)).toBe(true)
expect(Array.isArray(defaultValue.default_value)).toBe(true)
// Initial arrays should be empty // Initial arrays should be empty
expect(defaultValue.headers).toHaveLength(0) expect(defaultValue.headers).toHaveLength(0)
expect(defaultValue.params).toHaveLength(0) expect(defaultValue.params).toHaveLength(0)
expect(defaultValue.body).toHaveLength(0) expect(defaultValue.body).toHaveLength(0)
expect(defaultValue.default_value).toHaveLength(0)
}) })
it('should have empty prev nodes', () => { it('should have empty prev nodes', () => {
@ -55,7 +54,7 @@ describe('Webhook Trigger Node Default', () => {
describe('Validation - checkValid', () => { describe('Validation - checkValid', () => {
it('should validate successfully with default configuration', () => { it('should validate successfully with default configuration', () => {
const payload = nodeDefault.defaultValue const payload = nodeDefault.defaultValue as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT) const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true) expect(result.isValid).toBe(true)
@ -67,7 +66,7 @@ describe('Webhook Trigger Node Default', () => {
...nodeDefault.defaultValue, ...nodeDefault.defaultValue,
status_code: 404, status_code: 404,
response_body: '{"error": "Not found"}', response_body: '{"error": "Not found"}',
} } as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT) const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true) expect(result.isValid).toBe(true)
@ -77,7 +76,7 @@ describe('Webhook Trigger Node Default', () => {
const payload = { const payload = {
...nodeDefault.defaultValue, ...nodeDefault.defaultValue,
async_mode: false, async_mode: false,
} } as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT) const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true) expect(result.isValid).toBe(true)

View File

@ -224,7 +224,7 @@ const GenericTable: FC<GenericTableProps> = ({
</div> </div>
)} )}
<div className="divide-y divide-divider-subtle"> <div className="divide-y divide-divider-subtle">
{displayRows.map(({ row, dataIndex, isVirtual }, renderIndex) => { {displayRows.map(({ row, dataIndex, isVirtual: _isVirtual }, renderIndex) => {
const rowKey = `row-${renderIndex}` const rowKey = `row-${renderIndex}`
// Check if primary identifier column has content // Check if primary identifier column has content

View File

@ -2,7 +2,6 @@ import { BlockEnum } from '../../types'
import type { NodeDefault } from '../../types' import type { NodeDefault } from '../../types'
import type { WebhookTriggerNodeType } from './types' import type { WebhookTriggerNodeType } from './types'
import { ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks' import { ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
import type { DefaultValueForm } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
const nodeDefault: NodeDefault<WebhookTriggerNodeType> = { const nodeDefault: NodeDefault<WebhookTriggerNodeType> = {
defaultValue: { defaultValue: {
@ -15,7 +14,6 @@ const nodeDefault: NodeDefault<WebhookTriggerNodeType> = {
async_mode: true, async_mode: true,
status_code: 200, status_code: 200,
response_body: '', response_body: '',
default_value: [] as DefaultValueForm[],
}, },
getAvailablePrevNodes(_isChatMode: boolean) { getAvailablePrevNodes(_isChatMode: boolean) {
return [] return []

View File

@ -1,6 +1,4 @@
import type { CommonNodeType, InputVar } from '@/app/components/workflow/types' import type { CommonNodeType, InputVar } from '@/app/components/workflow/types'
import type { DefaultValueForm } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
import type { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD'
@ -28,8 +26,5 @@ export type WebhookTriggerNodeType = CommonNodeType & {
async_mode: boolean async_mode: boolean
status_code: number status_code: number
response_body: string response_body: string
http_methods?: HttpMethod[]
error_strategy?: ErrorHandleTypeEnum
default_value?: DefaultValueForm[]
variables: InputVar[] variables: InputVar[]
} }

View File

@ -5,8 +5,6 @@ import type { HttpMethod, WebhookHeader, WebhookParameter, WebhookTriggerNodeTyp
import { useNodesReadOnly } from '@/app/components/workflow/hooks' import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
import type { DefaultValueForm } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
import type { ErrorHandleTypeEnum } from '@/app/components/workflow/nodes/_base/components/error-handle/types'
import { fetchWebhookUrl } from '@/service/apps' import { fetchWebhookUrl } from '@/service/apps'
import type { InputVar } from '@/app/components/workflow/types' import type { InputVar } from '@/app/components/workflow/types'
import { InputVarType } from '@/app/components/workflow/types' import { InputVarType } from '@/app/components/workflow/types'
@ -124,18 +122,6 @@ const useConfig = (id: string, payload: WebhookTriggerNodeType) => {
})) }))
}, [inputs, setInputs]) }, [inputs, setInputs])
const handleErrorStrategyChange = useCallback((errorStrategy: ErrorHandleTypeEnum) => {
setInputs(produce(inputs, (draft) => {
draft.error_strategy = errorStrategy
}))
}, [inputs, setInputs])
const handleDefaultValueChange = useCallback((defaultValue: DefaultValueForm[]) => {
setInputs(produce(inputs, (draft) => {
draft.default_value = defaultValue
}))
}, [inputs, setInputs])
const generateWebhookUrl = useCallback(async () => { const generateWebhookUrl = useCallback(async () => {
// Idempotency: if we already have a URL, just return it. // Idempotency: if we already have a URL, just return it.
if (inputs.webhook_url && inputs.webhook_url.length > 0) if (inputs.webhook_url && inputs.webhook_url.length > 0)
@ -177,8 +163,6 @@ const useConfig = (id: string, payload: WebhookTriggerNodeType) => {
handleAsyncModeChange, handleAsyncModeChange,
handleStatusCodeChange, handleStatusCodeChange,
handleResponseBodyChange, handleResponseBodyChange,
handleErrorStrategyChange,
handleDefaultValueChange,
generateWebhookUrl, generateWebhookUrl,
} }
} }

View File

@ -350,5 +350,5 @@ export const getParallelInfo = (nodes: Node[], edges: Edge[], parentNodeId?: str
} }
export const hasErrorHandleNode = (nodeType?: BlockEnum) => { export const hasErrorHandleNode = (nodeType?: BlockEnum) => {
return nodeType === BlockEnum.LLM || nodeType === BlockEnum.Tool || nodeType === BlockEnum.HttpRequest || nodeType === BlockEnum.Code || nodeType === BlockEnum.TriggerWebhook return nodeType === BlockEnum.LLM || nodeType === BlockEnum.Tool || nodeType === BlockEnum.HttpRequest || nodeType === BlockEnum.Code
} }