In HTTP form-data, sys.files is of type Array[File], but unable to access files at specific indices in the array" #11907

Closed
opened 2026-02-21 19:04:40 -05:00 by yindo · 2 comments
Owner

Originally created by @jaybom on GitHub (Mar 20, 2025).

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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

In HTTP form-data, sys.files is of type Array[File], but unable to access files at specific indices in the array

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @jaybom on GitHub (Mar 20, 2025). ### 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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce In HTTP form-data, sys.files is of type Array[File], but unable to access files at specific indices in the array ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 19:04:40 -05:00
yindo closed this issue 2026-02-21 19:04:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 20, 2025):

Hey @jaybom! 👋 I'm here to help you with bug fixes, answer your questions, and assist you in becoming a contributor. Let's squash those bugs together!

I found a similar closed issue regarding accessing files at specific indices in an Array[File] when using HTTP form-data with sys.files. Unfortunately, no solution was found in the comments of that issue [1].

However, you can access files at specific indices by using the ArrayFileVariable to store multiple files and then retrieve them by their indices. Here's an example:

files = [
    File(
        tenant_id="1",
        type=FileType.IMAGE,
        transfer_method=FileTransferMethod.LOCAL_FILE,
        related_id="file1",
        filename="image1.jpg",
        mime_type="image/jpeg",
        storage_key="",
    ),
    File(
        tenant_id="1",
        type=FileType.DOCUMENT,
        transfer_method=FileTransferMethod.LOCAL_FILE,
        related_id="file2",
        filename="document.pdf",
        mime_type="application/pdf",
        storage_key="",
    ),
]

variable_pool.add(
    ["1111", "files"],
    ArrayFileVariable(
        name="files",
        value=files,
    ),
)

# Accessing files at specific indices
first_file = variable_pool.get(["1111", "files"]).value[0]  # Access the first file
second_file = variable_pool.get(["1111", "files"]).value[1]  # Access the second file

This code demonstrates how to store multiple files in an ArrayFileVariable, access them by index, and use them in an HTTP form-data request [2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 20, 2025): <!-- Greeting --> Hey @jaybom! 👋 I'm here to help you with bug fixes, answer your questions, and assist you in becoming a contributor. Let's squash those bugs together! <!-- Answer --> I found a similar closed issue regarding accessing files at specific indices in an `Array[File]` when using HTTP form-data with `sys.files`. Unfortunately, no solution was found in the comments of that issue <sup>[[1]](https://github.com/langgenius/dify/issues/12752)</sup>. However, you can access files at specific indices by using the `ArrayFileVariable` to store multiple files and then retrieve them by their indices. Here's an example: ```python files = [ File( tenant_id="1", type=FileType.IMAGE, transfer_method=FileTransferMethod.LOCAL_FILE, related_id="file1", filename="image1.jpg", mime_type="image/jpeg", storage_key="", ), File( tenant_id="1", type=FileType.DOCUMENT, transfer_method=FileTransferMethod.LOCAL_FILE, related_id="file2", filename="document.pdf", mime_type="application/pdf", storage_key="", ), ] variable_pool.add( ["1111", "files"], ArrayFileVariable( name="files", value=files, ), ) # Accessing files at specific indices first_file = variable_pool.get(["1111", "files"]).value[0] # Access the first file second_file = variable_pool.get(["1111", "files"]).value[1] # Access the second file ``` This code demonstrates how to store multiple files in an `ArrayFileVariable`, access them by index, and use them in an HTTP form-data request <sup>[[2]](https://github.com/langgenius/dify/blob/8165d0b46934af9c01253aaa88b3f52d00784249/api/tests/unit_tests/core/workflow/nodes/http_request/test_http_request_node.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f4b43155-c2ce-4b7b-8b96-85d95abbf3c2?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Mar 20, 2025):

It's supported in v1.0.1. fix: http_request node form-data support array[file] (#15731)

@crazywoola commented on GitHub (Mar 20, 2025): It's supported in v1.0.1. fix: http_request node form-data support array[file] (#15731)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#11907