Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
aixgeek opened this issue Jun 26, 2024 · 3 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@aixgeek
Copy link
Contributor

aixgeek commented Jun 26, 2024

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

@dosubot dosubot bot added the 🐞 bug Something isn't working label Jun 26, 2024
Copy link

dosubot bot commented 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.

@crazywoola
Copy link
Member

crazywoola commented Jun 26, 2024

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

@aixgeek
Copy link
Contributor Author

aixgeek commented Jun 26, 2024

I mean output var, not input var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants