output var validate keyAlreadyExists. This behavior prevent input. when outputs have same prefix. #4271

Closed
opened 2026-02-21 18:05:29 -05:00 by yindo · 3 comments
Owner

Originally created by @aixgeek on GitHub (Jun 26, 2024).

Originally assigned to: @JzoNgKVO on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.11

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

output var validate keyAlreadyExists. This behavior prevent input. when outputs have same prefix.
e.g.
result
result_b

I can't input result_b, because result is exists. Normally, the validation should be after blur confirm, not in input changing.

✔️ Expected Behavior

validate in blur, not in change.

Actual Behavior

validate in change. I can't change, delete, input...
image

Originally created by @aixgeek on GitHub (Jun 26, 2024). Originally assigned to: @JzoNgKVO on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.11 ### Cloud or Self Hosted Cloud, Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce output var validate keyAlreadyExists. This behavior prevent input. when outputs have same prefix. e.g. result result_b I can't input result_b, because result is exists. Normally, the validation should be after blur confirm, not in input changing. ### ✔️ Expected Behavior validate in blur, not in change. ### ❌ Actual Behavior validate in change. I can't change, delete, input... ![image](https://github.com/langgenius/dify/assets/9697715/3ce9b6f5-ab38-4e59-bc79-64d80ccd9830)
yindo added the 🐞 bug label 2026-02-21 18:05:29 -05:00
yindo closed this issue 2026-02-21 18:05:29 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 26, 2024):

To resolve the issue in Dify version 0.6.11 where validation of output variables with the same prefix prevents input, and to ensure that validation occurs on blur rather than during input changes, you can modify the handleVarKeyBlur function in the ConfigModal component. The handleVarKeyBlur function is already set up to perform validation on blur. Here is the relevant part of the code:

const handleVarKeyBlur = useCallback((e: any) => {
    if (tempPayload.label)
      return

    setTempPayload((prev) => {
      return {
        ...prev,
        label: e.target.value,
      }
    })
}, [tempPayload])

This function updates the label field of tempPayload when the input field loses focus (on blur). Additionally, the handlePayloadChange function ensures that validation occurs when the variable field is changed:

const handlePayloadChange = useCallback((key: string) => {
    return (value: any) => {
      if (key === 'variable') {
        const { isValid, errorKey, errorMessageKey } = checkKeys([value], true)
        if (!isValid) {
          Toast.notify({
            type: 'error',
            message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }),
          })
          return
        }
      }
      setTempPayload((prev) => {
        const newPayload = {
          ...prev,
          [key]: value,
        }

        return newPayload
      })
    }
}, [t])

This ensures that validation occurs on blur rather than during input changes, and prevents input issues with variables having the same prefix [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 26, 2024): <!-- Answer --> To resolve the issue in Dify version 0.6.11 where validation of output variables with the same prefix prevents input, and to ensure that validation occurs on blur rather than during input changes, you can modify the `handleVarKeyBlur` function in the `ConfigModal` component. The `handleVarKeyBlur` function is already set up to perform validation on blur. Here is the relevant part of the code: ```tsx const handleVarKeyBlur = useCallback((e: any) => { if (tempPayload.label) return setTempPayload((prev) => { return { ...prev, label: e.target.value, } }) }, [tempPayload]) ``` This function updates the `label` field of `tempPayload` when the input field loses focus (on blur). Additionally, the `handlePayloadChange` function ensures that validation occurs when the `variable` field is changed: ```tsx const handlePayloadChange = useCallback((key: string) => { return (value: any) => { if (key === 'variable') { const { isValid, errorKey, errorMessageKey } = checkKeys([value], true) if (!isValid) { Toast.notify({ type: 'error', message: t(`appDebug.varKeyError.${errorMessageKey}`, { key: errorKey }), }) return } } setTempPayload((prev) => { const newPayload = { ...prev, [key]: value, } return newPayload }) } }, [t]) ``` This ensures that validation occurs on blur rather than during input changes, and prevents input issues with variables having the same prefix <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/app/configuration/config-var/config-modal/index.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Jun 26, 2024):

You just input 2 arg1 in the image, and please provide the DSL accordingly.

@crazywoola commented on GitHub (Jun 26, 2024): You just input 2 arg1 in the image, and please provide the DSL accordingly.
Author
Owner

@aixgeek commented on GitHub (Jun 26, 2024):

I mean output var, not input var.

@aixgeek commented on GitHub (Jun 26, 2024): I mean output var, not input var.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4271