Skip to content

Bug: Dify 1.17.0 stores an invalid selector when an optional tool file input is cleared #41809

Open

Description

@stevenup

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for a bug report.
  • I searched existing open and closed issues.
  • I am submitting this report in English.
  • I did not modify the required issue sections.

Dify version

1.17.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Use a plugin tool with an optional file or files form parameter. For example:

parameters:
  - name: image
    type: files
    required: false
    label:
      en_US: Reference images
    human_description:
      en_US: Optional reference images.
    llm_description: Optional reference images.
    form: form

  - name: image_urls
    type: string
    required: false
    label:
      en_US: Reference image URLs
    human_description:
      en_US: Optional reference image URLs.
    llm_description: Optional reference image URLs.
    form: form
  1. Create a workflow with a Start node containing an Array[File] input.
  2. Add the plugin tool node.
  3. Select Start / input for the optional image parameter.
  4. Clear the selected variable.
  5. Save or run the workflow.

The cleared input is persisted as an empty variable selector instead of an unset value:

{"type":"variable","value":[]}

An empty string can also exist in serialized drafts:

{"type":"variable","value":""}

This was re-verified against the Dify 1.17.0 release tag (09a855dcef24c0edc7431c46c0cfaa494481daf5) and current main (0d8ad27b14d1efc19613b20018e5483fa93f8e5c, 2026-09-04).

The 1.17.0 runtime conversion path produces these failures for the two empty selector forms:

'': ValidationError: value must be a list
[]: ToolParameterError: Variable [] does not exist

Focused regression tests on current main also reproduce both sides before a fix:

  • Frontend: 2 failures; clearing optional file and files inputs emits {type: "variable", value: []}.
  • Backend: 4 failures; optional file and files inputs with "" or [] are validated or resolved instead of treated as unset.

✔️ Expected Behavior

Clearing an optional file or files parameter should restore a canonical unset state, such as:

{"type":"constant","value":null}

Existing drafts containing an empty optional variable selector should also run without trying to resolve that selector.

Required parameters and non-empty malformed selectors should retain their current validation behavior.

❌ Actual Behavior

Clearing an optional file selector keeps type: "variable" with an empty string or empty array value. Workflow execution then fails before the plugin is invoked with either value must be a list or Variable [] does not exist.

Activity

  1. stevenup commented on Sep 4, 2026

    @stevenup
    Author

    I would like to work on this fix and have a regression-tested patch ready. Could a maintainer please assign this issue to @stevenup?

  2. dosubot commented on Sep 4, 2026

    @dosubot

    @stevenup, this matches the same underlying bug from #39045, which was closed because the original report targeted Dify 1.13.0. The gap is still present on current main:

    • Frontend: handleVariableSelectorChange() always keeps type: VarKindType.variable and delegates to normalizeVariableSelectorValue(), which coerces a falsy (cleared) input to '' — it never resets to an unset constant.
    • Backend: _convert_tool_parameters_type() skips a parameter only when config.get("value") is not None. An empty string or empty list passes that check and gets validated as a real variable selector, producing either ValidationError: value must be a list or ToolParameterError: Variable [] does not exist.

    Your open PR #39195 already addresses both sides — resetting a cleared optional file/files selector to {"type":"constant","value":null} on the frontend, and having the backend ignore stale empty optional variable selectors — with regression tests covering the "" and [] cases.

    Since #39045 was closed for version-scope reasons rather than being resolved, and this report reconfirms the bug on 1.17.0 and current main, it may be worth a maintainer revisiting PR #39195 rather than requiring a fresh fix.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  3. added this to the 1.17.0 feedback milestone on Sep 7, 2026
  4. added
    review: low
    on Sep 22, 2026
  5. added
    1.17.0
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.17.0review: low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions