Unable to individually associate input_file, rules_file, stock_file in the "code execution" node, suspecting it's related to userinput.files. Requesting an official method to correctly map variables or handle legacy fields.

In the “Code Execution” node, input_file, rules_file, and stock_file cannot be individually associated, and it is suspected to be related to userinput.files. Requesting an official method to correctly map variables or handle legacy fields.

@Dify_Forum_Helper Please help me follow up for more information. I’ll send it to technical support later.

我这边先帮你向 TA 补充追问一些关键信息,方便技术支持后面排查:


@tiantian0920, I’d like to confirm a few things with you. Please provide the following when you have a moment:

  1. What is the current Dify version number you are using?

    • If it’s a self-hosted Docker, you can check the langgenius/dify tag in docker-compose.yml.
    • Or check the version number screenshot in “Settings → About”.
  2. What is your specific input field configuration?
    From the screenshot, the Start node has 3 file inputs:

    • input_file_ (Note: Is there a _ at the end or not?)
    • rules_file
    • stock_file
      In the “Input Variables” on the right side of the Code Execution node, 3 variables with the same names are also created. I’d like to confirm:
    • Are all 3 of these variables set to type File?
    • Is the code reading them using variables[\"input_file\"] / variables[\"rules_file\"] / variables[\"stock_file\"]? Please paste a small snippet of the key code (anonymized if necessary).
  3. What is the specific issue you are currently experiencing?

    • In the “Input Variables” section of the Code Execution node, can you select input_file_ / rules_file / stock_file separately in the dropdown list?
    • Or are all three variables only able to map to the same userinput.files (LEGACY)?
    • What is actually received at runtime:
      • Are all of them empty?
      • Or do the 3 variables actually receive the same file?
        Please attach a screenshot of the “Input Variable Mapping” configuration (the right-hand section) of the Code Execution node, and a screenshot of the actual variable values in the run log.
  4. Is this workflow copied/imported from an older version?
    Because userinput.files (LEGACY) is displayed here:

    • This field is usually a legacy field from older versions for “user uploaded file collection”.
    • I’d like to confirm: Is this workflow newly created, or copied/imported from a much older workflow?
    • If it’s copied from an old workflow, are there any hidden or deleted but not fully cleaned up old file fields in the Start node?
  5. What is your expected behavior?
    Do you want:

    • The user to upload 3 files for different purposes (input file / rules table / stock table) at once,
    • And then be able to retrieve them separately in the code as:
      input_file  # User input file
      rules_file  # Rules table
      stock_file  # Stock table
      

    Is that correct? Or do you want them to be merged into an array for processing?


I will also compile these questions for technical support:

  • The current UI simultaneously shows: individual file variables (input_file / rules_file / stock_file) and userinput.files (LEGACY). We need to confirm:
    • The correct mapping method now: Is it recommended to completely avoid userinput.files and instead directly bind the Code Execution node 1:1 to each file field?
    • For older workflows where userinput.files already exists, what is the officially recommended migration/cleanup method (e.g., recreating Start node fields + re-binding the code node, or is there a system-level migration logic)?
    • Could the LEGACY field interfere with the automatic mapping or runtime results of new fields?

Once you provide the above information and screenshots, I will forward them to technical support so they can provide official recommendations on the “correct variable mapping method” and “how to handle/migrate userinput.files (LEGACY)”.

  1. Version number V4.57.0

  2. It looks like this in the code

Here’s a summary of the confirmed information and suggestions for you to align with technical support:


1. Version & Code Status Overview

  • Your current version: v4.57.0
  • The code uses a function signature form:
def calculate_blank(input_file, rules_file, stock_file):
    df_input = pd.read_excel(input_file)
    df_rules = pd.read_excel(rules_file)
    df_stock = pd.read_excel(stock_file)

This indicates your expectation: in the ‘Code Execution’ node, you directly receive 3 separate file variables.


2. Dify’s Current ‘Recommended Approach’ (Combining Version and UI Changes)

In versions 4.x and later, file input has evolved from the earlier unified userinput.files to ‘each input field having an independent File variable’:

  • Start Node:

    • input_file_ (note that your screenshot seems to have a trailing _)
    • rules_file
    • stock_file
  • In the ‘Input Variables’ panel on the right side of the Code Execution node, you should configure it as follows (the core is 1:1 manual binding, not using userinput.files anymore):

    • Create 3 new input variables, all set to type File:
      • input_file → Map to ‘Start Node / input_file_’
      • rules_file → Map to ‘Start Node / rules_file’
      • stock_file → Map to ‘Start Node / stock_file’

    Then your code can directly use the function signature you provided.

userinput.files (LEGACY) is generally a compatibility field for unified file collections in older versions, and is no longer recommended in the new design, especially in scenarios like yours where multiple files with different business meanings need to be distinguished.


3. Recommended Self-Checks for You Now

  1. Are the variable names exactly the same?

    • The Start Node field is named input_file_, while in your function it’s input_file:
      • If the input variable in the right-side code node is input_file, but it’s actually mapped to the Start Node field input_file_, this is allowed (names are not required to be identical),
      • But you need to confirm: in the right-side ‘Input Variables → input_file’, the selected item in the dropdown is Start·input_file_, not userinput.files (LEGACY).
  2. Manually bind each variable to a specific field

    • On the right side of the Code Execution node:
      • For the input_file row, the source must be selected as: User Input · input_file_
      • rules_file → Select: User Input · rules_file
      • stock_file → Select: User Input · stock_file
    • If you still see userinput.files (LEGACY) in the dropdown, keep it unselected and do not configure any variables to point to it.
  3. Check variable value types at runtime

    • Print at the beginning of the code to confirm that you are getting file objects (not None or strings):
    import pandas as pd
    
    def calculate_blank(input_file, rules_file, stock_file):
        print("DEBUG input_file =", input_file)
        print("DEBUG rules_file =", rules_file)
        print("DEBUG stock_file =", stock_file)
    
        df_input = pd.read_excel(input_file)
        df_rules = pd.read_excel(rules_file)
        df_stock = pd.read_excel(stock_file)
        ...
    

    Then, in ‘Last Run’, check the values of the 3 variables to confirm if they correspond to the 3 Excel files you uploaded.


4. Recommendations for Handling userinput.files (LEGACY)

Based on the currently available information, you can proceed with the following ‘conservative approach’:

  1. Create / Recreate Start Node fields (if this workflow was copied or imported from an older version):

    • Confirm that the 3 input fields of the Start Node are indeed the new ‘File’ type, not the legacy merged fields.
    • If it was initially copied from an old flow, consider:
      • Adding 3 new File fields (e.g., input_file_new, etc.),
      • Remapping in the code node, and after confirming it works, then delete the old fields and userinput.files (LEGACY).
  2. No longer use userinput.files throughout the workflow:

    • Do not reference it in any node;
    • No longer rely on it for file distribution;
    • Truly read everything from individual File fields.

If the official documentation later provides clearer instructions on ‘how to clean up / migrate LEGACY fields’, you can follow those official steps for a final cleanup; but until then, ‘not using it + relying entirely on explicit fields’ is usually the safest approach.


5. Please provide a few more screenshots for precise technical support diagnosis

You’ve already provided the function code, which is very helpful. Two more screenshots would make it easier to pinpoint the issue:

  1. A full screenshot of the ‘Input Variables’ on the right side of the Code Execution node

    • This will show: which source field each of the three rows (input_file / rules_file / stock_file) is mapped to.
  2. ‘Last Run’ → Screenshot of the input data for that node

    • Show the actual values of these three variables at runtime (whether they are empty / whether they all become the same file).

Based on these two screenshots you provide, I will summarize the differences between ‘current behavior’ and ‘expected behavior’ into key points and forward them to technical support, highlighting:

  • The behavior when mixing new and old fields on v4.57.0;
  • Whether there’s a bug (e.g., the mapping UI allows selection, but at runtime they all point to the same file or are empty);
  • Whether userinput.files (LEGACY) can be completely hidden or migrated with one click.

If convenient, you can also mention: Is this workflow newly created, or was it copied/imported from an older version? This information will also affect the official troubleshooting direction.

  1. In the ‘Input Variables’ section of the code execution node, the dropdown list cannot individually select input_file_ / rules_file / stock_file; you can only click

screenshot(2)to select.

  1. I purchased remote installation by a technician; it’s a newly created workflow, not copied/imported from an old version.

  2. Want users to upload 3 files with different purposes at once (input file / rules table / inventory table),

  • And be able to get them separately in the code:

    input_file  # User input file
    rules_file  # Rules table
    stock_file  # Inventory table
    

Directly bind the code execution node 1:1 to each file field, don’t want userinput.files, otherwise, when setting the corresponding scalar values, the corresponding files cannot be selected.