Dify crashes with custom workflows with selection input #4763

Closed
opened 2026-02-21 18:07:54 -05:00 by yindo · 1 comment
Owner

Originally created by @dnyg on GitHub (Jul 24, 2024).

Originally assigned to: @iamjoel, @crazywoola 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.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When you have a custom tool that has an input which is a selection type, and you use it in another workflow, it crashes whenever you click the block in the workflow studio.

I assume because it is trying to render the input parameters, and it fails in my production build with the error

TypeError: r.slice(...).join is not a function

This error can originates from line 149 in .../_base/components/variable/var-reference-picker.tsx

The r value that is referred in the error message should supposedly be an array, but is instead the string "yes", which is one of the options in my selection type.

Adding a check before line 149 for checking if the value is a string, can fix the issue so the crash doesn't happen, but it doesn't give you a good UI experience for selecting values

Screenshot 2024-07-24 at 10 23 41

✔️ Expected Behavior

To not crash when I click a component

Actual Behavior

It crashes

Originally created by @dnyg on GitHub (Jul 24, 2024). Originally assigned to: @iamjoel, @crazywoola 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.15 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When you have a custom tool that has an input which is a selection type, and you use it in another workflow, it crashes whenever you click the block in the workflow studio. I assume because it is trying to render the input parameters, and it fails in my production build with the error >TypeError: r.slice(...).join is not a function This error can originates from line 149 in `.../_base/components/variable/var-reference-picker.tsx` The `r` value that is referred in the error message should supposedly be an array, but is instead the string "yes", which is one of the options in my selection type. Adding a check before line 149 for checking if the value is a string, can fix the issue so the crash doesn't happen, but it doesn't give you a good UI experience for selecting values <img width="905" alt="Screenshot 2024-07-24 at 10 23 41" src="https://github.com/user-attachments/assets/6a9ba66b-42a2-4abd-b157-4c8c49b8b524"> ### ✔️ Expected Behavior To not crash when I click a component ### ❌ Actual Behavior It crashes
yindo added the 🐞 bug🌊 feat:workflow labels 2026-02-21 18:07:54 -05:00
yindo closed this issue 2026-02-21 18:07:55 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 24, 2024):

Hey @dnyg! I'm here to help you with any bugs, questions, or contributions you have for the Dify repository. Let's work together to solve this issue.

The error you're encountering, TypeError: r.slice(...).join is not a function, occurs because the r variable is expected to be an array but is instead a string. This issue arises in the following files:

  1. workflow-variable-block/component.tsx
  2. _base/components/variable/var-reference-picker.tsx

In the var-reference-picker.tsx file, the r.slice(...).join operation is performed under specific conditions when determining the varName. The r variable should be of type ValueSelector, which is expected to be an array. However, in your case, it is receiving a string ("yes").

To resolve this issue, ensure that the value prop passed to the VarReferencePicker component is correctly typed as ValueSelector (an array) and not a string. You can add type checks and validation to ensure the value is always an array before performing operations on it.

Here is a relevant code snippet from var-reference-picker.tsx:

const varName = (() => {
    if (hasValue) {
      const isSystem = isSystemVar(value as ValueSelector)
      const varName = value.length >= 3 ? (value as ValueSelector).slice(-2).join('.') : value[value.length - 1]
      return `${isSystem ? 'sys.' : ''}${varName}`
    }
    return ''
  })()

Ensure that value is always an array before this operation. You might need to add validation or transformation logic to handle cases where value might be a string.

Additionally, review the workflow-variable-block/component.tsx file to ensure similar type validation and handling for the r variable.

By ensuring the correct type for the value prop, you can prevent the TypeError and avoid crashes when interacting with selection input types in custom workflows [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 24, 2024): <!-- Greeting --> Hey @dnyg! I'm here to help you with any bugs, questions, or contributions you have for the Dify repository. Let's work together to solve this issue. <!-- Answer --> The error you're encountering, `TypeError: r.slice(...).join is not a function`, occurs because the `r` variable is expected to be an array but is instead a string. This issue arises in the following files: 1. `workflow-variable-block/component.tsx` 2. `_base/components/variable/var-reference-picker.tsx` In the `var-reference-picker.tsx` file, the `r.slice(...).join` operation is performed under specific conditions when determining the `varName`. The `r` variable should be of type `ValueSelector`, which is expected to be an array. However, in your case, it is receiving a string ("yes"). To resolve this issue, ensure that the `value` prop passed to the `VarReferencePicker` component is correctly typed as `ValueSelector` (an array) and not a string. You can add type checks and validation to ensure the `value` is always an array before performing operations on it. Here is a relevant code snippet from `var-reference-picker.tsx`: ```tsx const varName = (() => { if (hasValue) { const isSystem = isSystemVar(value as ValueSelector) const varName = value.length >= 3 ? (value as ValueSelector).slice(-2).join('.') : value[value.length - 1] return `${isSystem ? 'sys.' : ''}${varName}` } return '' })() ``` Ensure that `value` is always an array before this operation. You might need to add validation or transformation logic to handle cases where `value` might be a string. Additionally, review the `workflow-variable-block/component.tsx` file to ensure similar type validation and handling for the `r` variable. By ensuring the correct type for the `value` prop, you can prevent the `TypeError` and avoid crashes when interacting with selection input types in custom workflows <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4763