Workflow remote file metadata falls back to URL guesses when HEAD is unsupported

オープン
#42,313 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

api/factories/file_factory/remote.py と get_remote_file_info() から始め、続いて api/tests/unit_tests/factories/test_file_factory.py の関連するケースを読んでください。対象を絞った file-factory テストを実行し、405 と 501 を返す HEAD レスポンスのカバレッジを、ファイル名のない URL のケースを含めて追加してください。ストリーミング GET のヘッダーからメタデータが提供され、ボディをバッファリングせずにレスポンスが閉じられ、成功する HEAD の動作が変更されず、テストがパスすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Self Checks
  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues and pull requests, including closed ones.
  • I confirm that I am using English to submit this report.
Dify version

main

Cloud or Self Hosted

Both

Problem

Workflow remote-file normalization obtains metadata in get_remote_file_info() through a HEAD request only. When an origin returns 405 Method Not Allowed or 501 Not Implemented for HEAD, while a normal GET succeeds, the helper skips response metadata and falls back to guesses from the URL path.

For signed download endpoints or URLs without a filename, this means a file with valid Content-Disposition, Content-Type, and Content-Length on GET is represented as a random .bin file with an unknown size. That can make workflow file-type normalization lose the actual file type even though the source is otherwise retrievable.

This is a separate path from the web reader fallback addressed by #42242. The affected workflow path is:

factories/file_factory/builders.py -> factories/file_factory/remote.py:get_remote_file_info().

Minimal reproduction

Use a remote URL such as https://example.test/download with these responses:

  • HEAD /download -> 405 Method Not Allowed
  • GET /download -> 200 OK, with:
Content-Disposition: attachment; filename="report.pdf"
Content-Type: application/pdf
Content-Length: 123

Current get_remote_file_info() returns a URL-derived or generated filename (for example <uuid>.bin), an empty/guessed MIME type, and -1 size because it only reads metadata after a 200 HEAD response.

Expected behavior: for 405 and 501 only, fall back to a streaming GET, use its headers to derive metadata, and close the response without buffering the file body. Existing behavior for successful HEAD responses and other HTTP statuses should remain unchanged.

Proposed scope
  • In api/factories/file_factory/remote.py, handle HEAD 405/501 by requesting a streaming GET and extracting only response headers.
  • Add focused tests in api/tests/unit_tests/factories/test_file_factory.py for both statuses and a URL without a filename.
  • Keep SSRF-safe access through remote_fetcher and do not alter unrelated remote-file download behavior.
主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。