fix: support custom file types in workflow Start node (#23672)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Guangdong Liu
2025-08-10 11:09:47 +08:00
committed by GitHub
parent 0be3b4e7a6
commit 79a3c1618f
2 changed files with 55 additions and 7 deletions

View File

@@ -168,7 +168,57 @@ def _extract_text_by_mime_type(*, file_content: bytes, mime_type: str) -> str:
def _extract_text_by_file_extension(*, file_content: bytes, file_extension: str) -> str: def _extract_text_by_file_extension(*, file_content: bytes, file_extension: str) -> str:
"""Extract text from a file based on its file extension.""" """Extract text from a file based on its file extension."""
match file_extension: match file_extension:
case ".txt" | ".markdown" | ".md" | ".html" | ".htm" | ".xml": case (
".txt"
| ".markdown"
| ".md"
| ".html"
| ".htm"
| ".xml"
| ".c"
| ".h"
| ".cpp"
| ".hpp"
| ".cc"
| ".cxx"
| ".c++"
| ".py"
| ".js"
| ".ts"
| ".jsx"
| ".tsx"
| ".java"
| ".php"
| ".rb"
| ".go"
| ".rs"
| ".swift"
| ".kt"
| ".scala"
| ".sh"
| ".bash"
| ".bat"
| ".ps1"
| ".sql"
| ".r"
| ".m"
| ".pl"
| ".lua"
| ".vim"
| ".asm"
| ".s"
| ".css"
| ".scss"
| ".less"
| ".sass"
| ".ini"
| ".cfg"
| ".conf"
| ".toml"
| ".env"
| ".log"
| ".vtt"
):
return _extract_text_from_plain_text(file_content) return _extract_text_from_plain_text(file_content)
case ".json": case ".json":
return _extract_text_from_json(file_content) return _extract_text_from_json(file_content)
@@ -194,8 +244,6 @@ def _extract_text_by_file_extension(*, file_content: bytes, file_extension: str)
return _extract_text_from_eml(file_content) return _extract_text_from_eml(file_content)
case ".msg": case ".msg":
return _extract_text_from_msg(file_content) return _extract_text_from_msg(file_content)
case ".vtt":
return _extract_text_from_vtt(file_content)
case ".properties": case ".properties":
return _extract_text_from_properties(file_content) return _extract_text_from_properties(file_content)
case _: case _:

View File

@@ -181,7 +181,7 @@ const FormItem: FC<Props> = ({
value={singleFileValue} value={singleFileValue}
onChange={handleSingleFileChange} onChange={handleSingleFileChange}
fileConfig={{ fileConfig={{
allowed_file_types: inStepRun allowed_file_types: inStepRun && (!payload.allowed_file_types || payload.allowed_file_types.length === 0)
? [ ? [
SupportUploadFileTypes.image, SupportUploadFileTypes.image,
SupportUploadFileTypes.document, SupportUploadFileTypes.document,
@@ -189,7 +189,7 @@ const FormItem: FC<Props> = ({
SupportUploadFileTypes.video, SupportUploadFileTypes.video,
] ]
: payload.allowed_file_types, : payload.allowed_file_types,
allowed_file_extensions: inStepRun allowed_file_extensions: inStepRun && (!payload.allowed_file_extensions || payload.allowed_file_extensions.length === 0)
? [ ? [
...FILE_EXTS[SupportUploadFileTypes.image], ...FILE_EXTS[SupportUploadFileTypes.image],
...FILE_EXTS[SupportUploadFileTypes.document], ...FILE_EXTS[SupportUploadFileTypes.document],
@@ -208,7 +208,7 @@ const FormItem: FC<Props> = ({
value={value} value={value}
onChange={files => onChange(files)} onChange={files => onChange(files)}
fileConfig={{ fileConfig={{
allowed_file_types: (inStepRun || isIteratorItemFile) allowed_file_types: (inStepRun || isIteratorItemFile) && (!payload.allowed_file_types || payload.allowed_file_types.length === 0)
? [ ? [
SupportUploadFileTypes.image, SupportUploadFileTypes.image,
SupportUploadFileTypes.document, SupportUploadFileTypes.document,
@@ -216,7 +216,7 @@ const FormItem: FC<Props> = ({
SupportUploadFileTypes.video, SupportUploadFileTypes.video,
] ]
: payload.allowed_file_types, : payload.allowed_file_types,
allowed_file_extensions: (inStepRun || isIteratorItemFile) allowed_file_extensions: (inStepRun || isIteratorItemFile) && (!payload.allowed_file_extensions || payload.allowed_file_extensions.length === 0)
? [ ? [
...FILE_EXTS[SupportUploadFileTypes.image], ...FILE_EXTS[SupportUploadFileTypes.image],
...FILE_EXTS[SupportUploadFileTypes.document], ...FILE_EXTS[SupportUploadFileTypes.document],