Workflow prompt marks valid plugin output variables invalid after refresh because command update reaches only first variable block

Open Beginner friendly
#40,041 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
frontend

Research direction

Start in web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx and inspect the UPDATE_WORKFLOW_NODES_MAP command handler. Add a regression test with multiple workflow variable block listeners and verify that every block receives the updated node map and available-variable metadata after refresh, leaving valid plugin output references without warnings.

Written by the indexing model from the issue text.

Description

Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template and fill in all the required fields.
Dify version

1.14.2. Source inspection confirms the same code is present in 1.14.0, 1.15.0, and current main.

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce
  1. Install a custom tool plugin whose output_schema defines multiple output variables, for example file_name, markdown, and processing_status.
  2. Add the tool to a workflow or an iteration.
  3. Add a downstream LLM node and insert all three tool output variables into its prompt.
  4. Save the workflow and refresh the browser page.
  5. Wait for the plugin metadata and workflow variables to finish loading.

After refresh, only the first variable block is shown as valid. The second and subsequent blocks display the orange "Invalid variable" warning even though:

  • all selectors use the correct tool node ID and output variable names;
  • all variables are present in the plugin output schema;
  • the workflow checklist may report no error;
  • interacting with the page or forcing another render can make the warnings disappear.

The issue is especially visible with plugin tool outputs because their variable metadata is populated asynchronously after the prompt's Lexical variable blocks have mounted.

Root cause

Each WorkflowVariableBlockComponent registers a listener for the same UPDATE_WORKFLOW_NODES_MAP Lexical command:

editor.registerCommand(
  UPDATE_WORKFLOW_NODES_MAP,
  (payload: UpdateWorkflowNodesMapPayload) => {
    setLocalWorkflowNodesMap(payload.workflowNodesMap)
    setLocalAvailableVariables(payload.availableVariables)
    return true
  },
  COMMAND_PRIORITY_EDITOR,
)

Returning true marks the command as handled and stops propagation to the remaining listeners. As a result, the asynchronous availableVariables update reaches only the first variable block in the prompt. Later blocks keep their initial empty or stale localAvailableVariables and incorrectly render the invalid-variable state.

Changing the listener return value to false allows every variable block to receive the broadcast:

return false

The behavior became observable after PR #34715 introduced availableVariables-based validation in WorkflowVariableBlockComponent. The handler returned true before that PR as well, but validation previously relied mainly on node existence, so the stopped broadcast did not produce this multi-variable false warning.

Relevant file:

web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx

Related but not duplicate:

  • #34714 / #34715 align prompt editor validation with checklist validation, but do not cover command propagation across multiple variable blocks.
  • #30608 concerns streaming tool outputs not being selectable downstream.
  • #38604 concerns unresolved Human Intervention variables during execution.
Expected Behavior

All workflow variable blocks in the prompt should receive the latest workflow node map and available-variable metadata. After refreshing the page, every valid tool output reference should remain valid and no false warning should be displayed.

Actual Behavior

Only the first workflow variable block receives the update after refresh. Subsequent valid variable references are displayed as invalid until another interaction or render updates the editor state.

Suggested regression test

Register multiple workflow variable block listeners, dispatch UPDATE_WORKFLOW_NODES_MAP, and assert that every listener receives the payload. At minimum, assert that the component command handler returns false, because this command is a broadcast rather than a single-consumer command.

Dominant language
TypeScript
Stars
157k
Forks
24.7k
Avg merge
22h 32m
Merged PRs (30d)
611

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify

All issues in langgenius/dify

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.