mirror of https://github.com/langgenius/dify.git
fix(webhook-trigger): remove error handling (#24902)
This commit is contained in:
parent
4d0ff5c281
commit
4ae19e6dde
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import nodeDefault from '../default'
|
||||
import type { WebhookTriggerNodeType } from '../types'
|
||||
|
||||
// Simple mock translation function
|
||||
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.params)).toBe(true)
|
||||
expect(Array.isArray(defaultValue.body)).toBe(true)
|
||||
expect(Array.isArray(defaultValue.default_value)).toBe(true)
|
||||
|
||||
// Initial arrays should be empty
|
||||
expect(defaultValue.headers).toHaveLength(0)
|
||||
expect(defaultValue.params).toHaveLength(0)
|
||||
expect(defaultValue.body).toHaveLength(0)
|
||||
expect(defaultValue.default_value).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('should have empty prev nodes', () => {
|
||||
|
|
@ -55,7 +54,7 @@ describe('Webhook Trigger Node Default', () => {
|
|||
|
||||
describe('Validation - checkValid', () => {
|
||||
it('should validate successfully with default configuration', () => {
|
||||
const payload = nodeDefault.defaultValue
|
||||
const payload = nodeDefault.defaultValue as WebhookTriggerNodeType
|
||||
|
||||
const result = nodeDefault.checkValid(payload, mockT)
|
||||
expect(result.isValid).toBe(true)
|
||||
|
|
@ -67,7 +66,7 @@ describe('Webhook Trigger Node Default', () => {
|
|||
...nodeDefault.defaultValue,
|
||||
status_code: 404,
|
||||
response_body: '{"error": "Not found"}',
|
||||
}
|
||||
} as WebhookTriggerNodeType
|
||||
|
||||
const result = nodeDefault.checkValid(payload, mockT)
|
||||
expect(result.isValid).toBe(true)
|
||||
|
|
@ -77,7 +76,7 @@ describe('Webhook Trigger Node Default', () => {
|
|||
const payload = {
|
||||
...nodeDefault.defaultValue,
|
||||
async_mode: false,
|
||||
}
|
||||
} as WebhookTriggerNodeType
|
||||
|
||||
const result = nodeDefault.checkValid(payload, mockT)
|
||||
expect(result.isValid).toBe(true)
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ const GenericTable: FC<GenericTableProps> = ({
|
|||
</div>
|
||||
)}
|
||||
<div className="divide-y divide-divider-subtle">
|
||||
{displayRows.map(({ row, dataIndex, isVirtual }, renderIndex) => {
|
||||
{displayRows.map(({ row, dataIndex, isVirtual: _isVirtual }, renderIndex) => {
|
||||
const rowKey = `row-${renderIndex}`
|
||||
|
||||
// Check if primary identifier column has content
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { BlockEnum } from '../../types'
|
|||
import type { NodeDefault } from '../../types'
|
||||
import type { WebhookTriggerNodeType } from './types'
|
||||
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> = {
|
||||
defaultValue: {
|
||||
|
|
@ -15,7 +14,6 @@ const nodeDefault: NodeDefault<WebhookTriggerNodeType> = {
|
|||
async_mode: true,
|
||||
status_code: 200,
|
||||
response_body: '',
|
||||
default_value: [] as DefaultValueForm[],
|
||||
},
|
||||
getAvailablePrevNodes(_isChatMode: boolean) {
|
||||
return []
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
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'
|
||||
|
||||
|
|
@ -28,8 +26,5 @@ export type WebhookTriggerNodeType = CommonNodeType & {
|
|||
async_mode: boolean
|
||||
status_code: number
|
||||
response_body: string
|
||||
http_methods?: HttpMethod[]
|
||||
error_strategy?: ErrorHandleTypeEnum
|
||||
default_value?: DefaultValueForm[]
|
||||
variables: InputVar[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import type { HttpMethod, WebhookHeader, WebhookParameter, WebhookTriggerNodeTyp
|
|||
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
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 type { InputVar } from '@/app/components/workflow/types'
|
||||
import { InputVarType } from '@/app/components/workflow/types'
|
||||
|
|
@ -124,18 +122,6 @@ const useConfig = (id: string, payload: WebhookTriggerNodeType) => {
|
|||
}))
|
||||
}, [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 () => {
|
||||
// Idempotency: if we already have a URL, just return it.
|
||||
if (inputs.webhook_url && inputs.webhook_url.length > 0)
|
||||
|
|
@ -177,8 +163,6 @@ const useConfig = (id: string, payload: WebhookTriggerNodeType) => {
|
|||
handleAsyncModeChange,
|
||||
handleStatusCodeChange,
|
||||
handleResponseBodyChange,
|
||||
handleErrorStrategyChange,
|
||||
handleDefaultValueChange,
|
||||
generateWebhookUrl,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,5 +350,5 @@ export const getParallelInfo = (nodes: Node[], edges: Edge[], parentNodeId?: str
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue