Skip to content

Automate browser based workflows with AI

Parse ZIP unzip-only: File Parser always outputs extracted file list for ZIPs (SKY-13279) (#7899)

Suchintan7855da675eac
diff --git a/docs/cloud/building-agents/configure-blocks.mdx b/docs/cloud/building-agents/configure-blocks.mdx
index bda4fd9ca..bcc8baf57 100644
--- a/docs/cloud/building-agents/configure-blocks.mdx
+++ b/docs/cloud/building-agents/configure-blocks.mdx
@@ -218,7 +218,9 @@ Send text to the LLM for processing without browser interaction. Useful for summ
### File Parser
-Parse PDFs, CSVs, Excel files, and images to extract structured data.
+Parse PDFs, CSVs, Excel files, images, DOCX files, and ZIP archives.
+
+ZIP inputs are unzipped, and the block outputs the extracted file list as `file_name`, `file_path`, and `file_size`. Data Schema is ignored for ZIP inputs; loop over the file list and pass each `file_path` to another File Parser block to parse individual files.
| Field | Type | Description |
|-------|------|-------------|
diff --git a/docs/developers/browser-automations/work-with-files.mdx b/docs/developers/browser-automations/work-with-files.mdx
index a44a71078..b3cd3acbf 100644
--- a/docs/developers/browser-automations/work-with-files.mdx
+++ b/docs/developers/browser-automations/work-with-files.mdx
@@ -166,13 +166,15 @@ If you build agents in the Cloud UI, file operations use dedicated blocks instea
| Block | Purpose |
|-------|---------|
| **File Download** | Download files during agent execution |
-| **File Parser** | Parse PDFs, CSVs, and Excel files |
+| **File Parser** | Parse PDFs, CSVs, Excel files, images, and DOCX files; unzip ZIP archives |
| **Download to S3** | Save files from URLs to Skyvern's S3 |
| **Upload to S3** | Upload agent files to S3 |
| **File Upload** | Upload to your own S3 or Azure Blob Storage |
Files downloaded during an agent run accumulate in a temporary directory and can be passed between blocks using agent parameters. See [Agent Blocks Reference](/cloud/building-agents/configure-blocks) for block configuration details.
+For ZIP inputs, File Parser outputs the extracted files as `file_name`, `file_path`, and `file_size`. Data Schema is ignored for ZIP inputs; loop over the file list and pass each `file_path` to another File Parser block to parse individual files.
+
---
## Full reference
diff --git a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
index ef02a5e29..d8a9da013 100644
--- a/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
+++ b/skyvern-frontend/src/routes/workflows/editor/helpContent.ts
@@ -202,7 +202,7 @@ export const helpTooltips = {
fileUrl:
"Since we're in beta this section isn't fully customizable yet, contact us if you'd like to integrate it into your workflow.",
fileType:
- "The format of the file to parse. Auto-detected from the URL extension when possible. ZIP archives are unzipped: without a data schema the block outputs the list of extracted files; with a schema it parses the files inside and extracts against the schema.",
+ "The format of the file to parse. Auto-detected from the URL extension when possible. ZIP archives are always unzipped, and the block outputs the extracted files as file_name, file_path, and file_size. Data Schema is ignored for ZIPs. To parse contained files, loop over the output and pass each file_path to another File Parser block.",
},
wait: {
...baseHelpTooltipContent,
diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/FileParserNode/FileParserEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/FileParserNode/FileParserEditor.tsx
index aa447419b..5707cfa6a 100644
--- a/skyvern-frontend/src/routes/workflows/editor/nodes/FileParserNode/FileParserEditor.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/FileParserNode/FileParserEditor.tsx
@@ -150,12 +150,22 @@ function FileParserEditorBody({
</SelectContent>
</Select>
</div>
- <WorkflowDataSchemaInputGroup
- exampleValue={dataSchemaExampleForFileExtraction}
- value={data.jsonSchema}
- onChange={(value) => update({ jsonSchema: value })}
- suggestionContext={{ current_schema: data.jsonSchema }}
- />
+ <div className="space-y-2">
+ <WorkflowDataSchemaInputGroup
+ exampleValue={dataSchemaExampleForFileExtraction}
+ value={data.jsonSchema}
+ onChange={(value) => update({ jsonSchema: value })}
+ suggestionContext={{ current_schema: data.jsonSchema }}
+ />
+ {(data.fileType === "zip" ||
+ ((data.fileType === "auto_detect" || data.fileType === "csv") &&
+ detectFileTypeFromUrl(data.fileUrl ?? "") === "zip")) && (
+ <p className="text-xs text-muted-foreground dark:text-slate-500">
+ Data Schema is ignored for ZIP archives. This block outputs the
+ extracted file list.
+ </p>
+ )}
+ </div>
<ModelSelector
className="nopan w-52 text-xs"
value={data.model}
diff --git a/skyvern-frontend/src/routes/workflows/editor/panels/BlockConfigForm/FileParserBlockForm.test.tsx b/skyvern-frontend/src/routes/workflows/editor/panels/BlockConfigForm/FileParserBlockForm.test.tsx
index 211fda8b9..5440b9b4d 100644
--- a/skyvern-frontend/src/routes/workflows/editor/panels/BlockConfigForm/FileParserBlockForm.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/panels/BlockConfigForm/FileParserBlockForm.test.tsx
@@ -168,6 +168,40 @@ describe("FileParserBlockForm (SKY-9381)", () => {
).toBeTruthy();
});
+ test("shows the ZIP output hint without hiding the schema input", () => {
+ mockNodeFixtures.set("fp1", {
+ id: "fp1",
+ type: "fileParser",
+ data: { ...baseFileParserData, fileType: "zip" as const },
+ });
+ render(<FileParserBlockForm blockId="fp1" />);
+
+ expect(
+ screen.getByText(/Data Schema is ignored for ZIP archives/),
+ ).toBeDefined();
+ expect(screen.getByTestId("json-schema-input")).toBeDefined();
+ });
+
+ test.each(["csv", "auto_detect"] as const)(
+ "shows the ZIP output hint for %s blocks with a ZIP URL",
+ (fileType) => {
+ mockNodeFixtures.set("fp1", {
+ id: "fp1",
+ type: "fileParser",
+ data: {
+ ...baseFileParserData,
+ fileType,
+ fileUrl: "https://example.com/archive.zip",
+ },
+ });
+ render(<FileParserBlockForm blockId="fp1" />);
+
+ expect(
+ screen.getByText(/Data Schema is ignored for ZIP archives/),
+ ).toBeDefined();
+ },
+ );
+
test("File URL onChange dispatches updateNodeData via useUpdate (byte-identical write)", () => {
mockNodeFixtures.set("fp1", {
id: "fp1",
diff --git a/skyvern/cli/mcp_tools/blocks.py b/skyvern/cli/mcp_tools/blocks.py
index 903be8a70..e10c8017f 100644
--- a/skyvern/cli/mcp_tools/blocks.py
+++ b/skyvern/cli/mcp_tools/blocks.py
@@ -115,7 +115,7 @@ BLOCK_SUMMARIES: dict[str, str] = {
"goto_url": "Navigate directly to a URL without additional instructions",
"download_to_s3": "Download a URL directly to S3 storage",
"upload_to_s3": "Upload local content to S3",
- "file_url_parser": "Parse a file (CSV/Excel/PDF/image) from a URL",
+ "file_url_parser": "Parse a file (CSV/Excel/PDF/image/DOCX) from a URL; ZIP archives are unzipped to a file list",
"pdf_parser": "Extract structured data from a PDF document",
"human_interaction": "Pause workflow for human approval via email",
"print_page": "Print the current page to PDF",
diff --git a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
index 3b2ce32ef..220c22a3d 100644
--- a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
+++ b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt
@@ -662,11 +662,12 @@ Use Cases:
- Parse a PDF invoice into structured fields
- Extract rows from a CSV file
- Read Excel sheets for downstream processing
-- Unzip a ZIP archive of PDFs and extract structured data across all of them
+- Unzip a ZIP archive (always outputs [{file_name, file_path, file_size}]; json_schema is ignored for ZIPs) and parse each extracted file in a loop
ZIP behavior:
-- Without json_schema: outputs the list of extracted files as [{file_name, file_path, file_size}]. Loop over the output and pass each file_path as the file_url of another file_url_parser block to parse files individually.
-- With json_schema: parses every supported file inside the archive (CSV/Excel/PDF/image/DOCX) and extracts against the schema from the combined content.
+- A File Parser pointed at a ZIP always unzips it and outputs [{file_name, file_path, file_size}].
+- json_schema is ignored for ZIP archives.
+- To extract structured data from contained files, use File Parser (ZIP to file list) -> for-loop over the output -> File Parser for each run-local file_path, passed as file_url.
Example:
blocks:
diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py
index cff94721f..71149bac6 100644
--- a/skyvern/forge/sdk/workflow/models/block.py
+++ b/skyvern/forge/sdk/workflow/models/block.py
@@ -8573,77 +8573,6 @@ class FileParserBlock(Block):
return await self._parse_docx_file(file_path)
return None
- async def _parse_zip_contents(
- self,
- extracted_files: list[dict[str, Any]],
- workflow_run_block_id: str | None = None,
- organization_id: str | None = None,
- ) -> list[dict[str, Any]]:
- """Parse every supported file extracted from a ZIP for combined AI extraction.
-
- Returns [{"file_name", "content"}, ...]. Unsupported or unparseable files are skipped;
- total content is truncated at a file boundary once MAX_FILE_PARSE_INPUT_TOKENS is reached.
- """
- content_entries: list[dict[str, Any]] = []
- current_tokens = 0
- for file_info in extracted_files:
- inner_path: str = file_info["file_path"]
- file_name: str = file_info["file_name"]
- try:
- inner_file_type = self._detect_file_type_from_url(inner_path, file_path=inner_path)
- except InvalidFileType as e:
- LOG.warning("FileParserBlock Skipping unsupported file in ZIP", file_name=file_name, error=str(e))
- continue
- if inner_file_type == FileType.ZIP:
- LOG.warning("FileParserBlock Skipping nested ZIP archive", file_name=file_name)
- continue
- try:
- content = await self._parse_file_of_type(
- inner_file_type,
- inner_path,
- workflow_run_block_id=workflow_run_block_id,
- organization_id=organization_id,
- )
- except Exception as e:
- LOG.warning(
- "FileParserBlock Failed to parse file in ZIP, skipping it", file_name=file_name, error=str(e)
- )
- continue
- if content is None:
- LOG.warning(
- "FileParserBlock Skipping file with unsupported type in ZIP",
- file_name=file_name,
- detected_file_type=inner_file_type,
- )
- continue
- entry = {"file_name": file_name, "content": content}
- entry_tokens = count_tokens(json.dumps(entry, separators=(",", ":"), default=str))
- if current_tokens + entry_tokens > MAX_FILE_PARSE_INPUT_TOKENS:
- if not content_entries:
- raise InvalidFileType(
- file_url=self.file_url,
- file_type=self.file_type,
- error=f"File '{file_name}' in the ZIP archive alone exceeds the maximum extraction input size",
- )
- LOG.warning(
- "FileParserBlock ZIP content exceeds token limit, truncating at file boundary",
- file_url=self.file_url,
- files_included=len(content_entries),
- total_files=len(extracted_files),
- max_tokens=MAX_FILE_PARSE_INPUT_TOKENS,
- )
- break
- current_tokens += entry_tokens
- content_entries.append(entry)
-
- if not content_entries:
- raise InvalidFileType(
- file_url=self.file_url,
- file_type=self.file_type,
- error="ZIP archive contains no parseable files (supported: CSV, Excel, PDF, image, DOCX)",
- )
- return content_entries
-
async def _extract_with_ai(
self,
content: str | list[dict[str, Any]],
@@ -8862,14 +8791,7 @@ class FileParserBlock(Block):
extracted_zip_files = await asyncio.to_thread(
self._extract_zip_file, file_path, workflow_run_id, workflow_run_block_id
)
- if self.json_schema:
- parsed_data = await self._parse_zip_contents(
- extracted_zip_files,
- workflow_run_block_id=workflow_run_block_id,
- organization_id=organization_id,
- )
- else:
- parsed_data = extracted_zip_files
+ parsed_data = extracted_zip_files
else:
maybe_parsed = await self._parse_file_of_type(
self.file_type,
@@ -8895,7 +8817,6 @@ class FileParserBlock(Block):
f"Failed to parse {self.file_type} file: {str(e)}",
)
- # If json_schema is provided, use AI to extract structured data
final_data: Any
LOG.debug(
"FileParserBlock JSON schema check",
@@ -8904,7 +8825,14 @@ class FileParserBlock(Block):
json_schema=self.json_schema,
)
- if self.json_schema:
+ if self.file_type == FileType.ZIP:
+ if self.json_schema:
+ LOG.warning(
+ "FileParserBlock json_schema is ignored for ZIP archives; returning extracted file list",
+ file_url=self.file_url,
+ )
+ final_data = parsed_data
+ elif self.json_schema:
try:
ai_extracted_data = await self._extract_with_ai(
parsed_data,
diff --git a/tests/unit/workflow/test_file_parser_zip.py b/tests/unit/workflow/test_file_parser_zip.py
index 103550ff2..b307a6fa7 100644
--- a/tests/unit/workflow/test_file_parser_zip.py
+++ b/tests/unit/workflow/test_file_parser_zip.py
@@ -2,13 +2,12 @@
Tests for FileParserBlock ZIP support (SKY-11711).
Covers ZIP detection, validation, safe extraction (junk filtering, zip-bomb caps,
-traversal), per-file content parsing for AI extraction, and local-path file_url
-handling (applies to all file types).
+traversal), unzip-only execution, and local-path file_url handling (applies to
+all file types).
"""
from __future__ import annotations
-import json
import zipfile
from datetime import datetime, timezone
from pathlib import Path
@@ -282,87 +281,6 @@ class TestExtractZipFile:
assert extracted[0]["file_size"] == len(b"second version")
-class TestParseZipContents:
- @staticmethod
- def _file_info(path: Path, root: Path) -> dict[str, Any]:
- return {
- "file_name": str(path.relative_to(root)),
- "file_path": str(path),
- "file_size": path.stat().st_size,
- }
-
- async def test_parses_supported_files_and_skips_unparseable(self, tmp_path: Path) -> None:
- csv_path = tmp_path / "data.csv"
- csv_path.write_text("name,age\nAlice,30")
- docx_path = tmp_path / "doc.docx"
- _create_docx_bytes("Report body", docx_path)
- nested_zip = _create_zip(tmp_path / "inner.zip", {"x.txt": b"nested"})
- binary_path = tmp_path / "blob.bin"
- binary_path.write_bytes(b"\x00\x01\x02\x03")
-
- block = _make_file_parser_block("https://example.com/archive.zip", FileType.ZIP)
- entries = await block._parse_zip_contents(
- [
- self._file_info(csv_path, tmp_path),
- self._file_info(docx_path, tmp_path),
- self._file_info(nested_zip, tmp_path),
- self._file_info(binary_path, tmp_path),
- ]
- )
-
- assert entries == [
- {"file_name": "data.csv", "content": [{"name": "Alice", "age": "30"}]},
- {"file_name": "doc.docx", "content": "Report body"},
- ]
-
- async def test_pdf_files_parsed_via_pdf_parser(self, tmp_path: Path) -> None:
- pdf_path = tmp_path / "report.pdf"
- pdf_path.write_bytes(b"%PDF-1.5 fake")
-
- block = _make_file_parser_block("https://example.com/archive.zip", FileType.ZIP)
- with pytest.MonkeyPatch.context() as mp:
- mp.setattr(FileParserBlock, "_parse_pdf_file", AsyncMock(return_value="pdf text content"))
- entries = await block._parse_zip_contents([self._file_info(pdf_path, tmp_path)])
-
- assert entries == [{"file_name": "report.pdf", "content": "pdf text content"}]
-
- async def test_truncates_at_file_boundary_on_token_limit(self, tmp_path: Path) -> None:
- first = tmp_path / "a.csv"
- first.write_text("h\n1")
- second = tmp_path / "b.csv"
- second.write_text("h\n2")
-
- block = _make_file_parser_block("https://example.com/archive.zip", FileType.ZIP)
- with pytest.MonkeyPatch.context() as mp:
- mp.setattr("skyvern.forge.sdk.workflow.models.block.count_tokens", lambda text: 10)
- mp.setattr("skyvern.forge.sdk.workflow.models.block.MAX_FILE_PARSE_INPUT_TOKENS", 15)
- entries = await block._parse_zip_contents(
- [self._file_info(first, tmp_path), self._file_info(second, tmp_path)]
- )
-
- assert [entry["file_name"] for entry in entries] == ["a.csv"]
-
- async def test_no_parseable_files_raises(self, tmp_path: Path) -> None:
- binary_path = tmp_path / "blob.bin"
- binary_path.write_bytes(b"\x00\x01\x02\x03")
-
- block = _make_file_parser_block("https://example.com/archive.zip", FileType.ZIP)
- with pytest.raises(InvalidFileType, match="no parseable files"):
- await block._parse_zip_contents([self._file_info(binary_path, tmp_path)])
-
- async def test_first_file_over_budget_raises(self, tmp_path: Path) -> None:
- csv_path = tmp_path / "data.csv"
- csv_path.write_text("h\n1")
-
- block = _make_file_parser_block("https://example.com/archive.zip", FileType.ZIP)
- with pytest.MonkeyPatch.context() as mp:
- mp.setattr("skyvern.forge.sdk.workflow.models.block.count_tokens", lambda text: 100)
- mp.setattr("skyvern.forge.sdk.workflow.models.block.MAX_FILE_PARSE_INPUT_TOKENS", 15)
- with pytest.raises(InvalidFileType, match="alone exceeds the maximum extraction input size"):
- await block._parse_zip_contents([self._file_info(csv_path, tmp_path)])
-
-
@pytest.mark.asyncio
class TestExecuteWithZipAndLocalPaths:
@staticmethod
@@ -420,7 +338,7 @@ class TestExecuteWithZipAndLocalPaths:
assert result.output_parameter_value == [{"name": "Alice", "age": "30"}]
download_mock.assert_not_awaited()
- async def test_execute_zip_with_schema_runs_combined_ai_extraction(self, tmp_path: Path) -> None:
+ async def test_execute_zip_with_schema_outputs_file_list_without_llm(self, tmp_path: Path) -> None:
zip_path = _create_zip(tmp_path / "archive.zip", {"data.csv": b"name,age\nAlice,30"})
block = _make_file_parser_block("https://example.com/archive.zip")
block.json_schema = {"type": "object"}
@@ -428,21 +346,144 @@ class TestExecuteWithZipAndLocalPaths:
with pytest.MonkeyPatch.context() as mp:
record_output = self._patch_execute_dependencies(mp, tmp_path)
mp.setattr("skyvern.forge.sdk.api.files.download_file", AsyncMock(return_value=str(zip_path)))
+ handler = AsyncMock()
+ mp.setattr(
+ "skyvern.forge.sdk.workflow.models.block.LLMAPIHandlerFactory.get_override_llm_api_handler",
+ lambda *a, **kw: handler,
+ )
+
+ result = await block.execute("wr_test", "wrb_test", organization_id="org-1")
+
+ assert result.success is True
+ assert result.output_parameter_value == [
+ {
+ "file_name": "data.csv",
+ "file_path": str(tmp_path / "downloads" / "wr_test" / "unzipped" / "archive_wrb_test" / "data.csv"),
+ "file_size": len(b"name,age\nAlice,30"),
+ }
+ ]
+ handler.assert_not_awaited()
+ record_output.assert_awaited_once()
+ assert record_output.await_args.args[2] == result.output_parameter_value
+
+ async def test_execute_explicit_zip_with_schema_outputs_file_list_without_llm(self, tmp_path: Path) -> None:
+ zip_path = _create_zip(tmp_path / "explicit.zip", {"nested/data.csv": b"name,age\nAlice,30"})
+ block = _make_file_parser_block("https://example.com/explicit.zip", FileType.ZIP)
+ block.json_schema = {"type": "object"}
+
+ with pytest.MonkeyPatch.context() as mp:
+ record_output = self._patch_execute_dependencies(mp, tmp_path)
+ mp.setattr("skyvern.forge.sdk.api.files.download_file", AsyncMock(return_value=str(zip_path)))
+ handler = AsyncMock()
+ mp.setattr(
+ "skyvern.forge.sdk.workflow.models.block.LLMAPIHandlerFactory.get_override_llm_api_handler",
+ lambda *a, **kw: handler,
+ )
+
+ result = await block.execute("wr_test", "wrb_explicit", organization_id="org-1")
+
+ assert result.success is True
+ assert result.output_parameter_value == [
+ {
+ "file_name": "nested/data.csv",
+ "file_path": str(
+ tmp_path / "downloads" / "wr_test" / "unzipped" / "explicit_wrb_explicit" / "nested" / "data.csv"
+ ),
+ "file_size": len(b"name,age\nAlice,30"),
+ }
+ ]
+ handler.assert_not_awaited()
+ record_output.assert_awaited_once()
+ assert record_output.await_args.args[2] == result.output_parameter_value
+
+ async def test_execute_auto_detected_zip_with_schema_outputs_file_list_without_llm(self, tmp_path: Path) -> None:
+ zip_path = _create_zip(tmp_path / "download", {"report.pdf": b"not parsed"})
+ block = _make_file_parser_block("https://example.com/download?id=123")
+ block.json_schema = {"type": "object"}
+
+ with pytest.MonkeyPatch.context() as mp:
+ record_output = self._patch_execute_dependencies(mp, tmp_path)
+ mp.setattr("skyvern.forge.sdk.api.files.download_file", AsyncMock(return_value=str(zip_path)))
+ handler = AsyncMock()
+ mp.setattr(
+ "skyvern.forge.sdk.workflow.models.block.LLMAPIHandlerFactory.get_override_llm_api_handler",
+ lambda *a, **kw: handler,
+ )
+
+ result = await block.execute("wr_test", "wrb_auto", organization_id="org-1")
+
+ assert result.success is True
+ assert result.output_parameter_value == [
+ {
+ "file_name": "report.pdf",
+ "file_path": str(tmp_path / "downloads" / "wr_test" / "unzipped" / "download_wrb_auto" / "report.pdf"),
+ "file_size": len(b"not parsed"),
+ }
+ ]
+ handler.assert_not_awaited()
+ record_output.assert_awaited_once()
+ assert record_output.await_args.args[2] == result.output_parameter_value
+
+ async def test_execute_run_local_zip_with_schema_outputs_file_list_without_llm(self, tmp_path: Path) -> None:
+ run_dir = tmp_path / "downloads" / "wr_test"
+ run_dir.mkdir(parents=True)
+ zip_path = _create_zip(run_dir / "local.zip", {"report.pdf": b"not parsed"})
+ block = _make_file_parser_block(str(zip_path))
+ block.json_schema = {"type": "object"}
+
+ with pytest.MonkeyPatch.context() as mp:
+ record_output = self._patch_execute_dependencies(mp, tmp_path)
+ download_mock = AsyncMock(side_effect=AssertionError("download_file must not be called"))
+ mp.setattr("skyvern.forge.sdk.api.files.download_file", download_mock)
+ handler = AsyncMock()
+ mp.setattr(
+ "skyvern.forge.sdk.workflow.models.block.LLMAPIHandlerFactory.get_override_llm_api_handler",
+ lambda *a, **kw: handler,
+ )
+
+ result = await block.execute("wr_test", "wrb_local", organization_id="org-1")
+
+ assert result.success is True
+ assert result.output_parameter_value == [
+ {
+ "file_name": "report.pdf",
+ "file_path": str(tmp_path / "downloads" / "wr_test" / "unzipped" / "local_wrb_local" / "report.pdf"),
+ "file_size": len(b"not parsed"),
+ }
+ ]
+ download_mock.assert_not_awaited()
+ handler.assert_not_awaited()
+ record_output.assert_awaited_once()
+ assert record_output.await_args.args[2] == result.output_parameter_value
+
+ @pytest.mark.parametrize(
+ "zip_files",
+ [{}, {"__MACOSX/._report.pdf": b"junk", ".DS_Store": b"junk"}],
+ ids=["empty", "junk-only"],
+ )
+ async def test_execute_empty_or_junk_only_zip_with_schema_outputs_empty_list(
+ self, tmp_path: Path, zip_files: dict[str, bytes]
+ ) -> None:
+ zip_path = _create_zip(tmp_path / "archive.zip", zip_files)
+ block = _make_file_parser_block("https://example.com/archive.zip")
+ block.json_schema = {"type": "object"}
+
+ with pytest.MonkeyPatch.context() as mp:
+ record_output = self._patch_execute_dependencies(mp, tmp_path)
+ mp.setattr("skyvern.forge.sdk.api.files.download_file", AsyncMock(return_value=str(zip_path)))
+ handler = AsyncMock()
mp.setattr(
"skyvern.forge.sdk.workflow.models.block.LLMAPIHandlerFactory.get_override_llm_api_handler",
- lambda *a, **kw: AsyncMock(return_value={"answer": 42}),
+ lambda *a, **kw: handler,
)
- mock_load = MagicMock(return_value="prompt")
- mp.setattr("skyvern.forge.sdk.workflow.models.block.prompt_engine.load_prompt", mock_load)
result = await block.execute("wr_test", "wrb_test", organization_id="org-1")
assert result.success is True
- assert result.output_parameter_value == {"answer": 42}
- _, kwargs = mock_load.call_args
- content_entries = json.loads(kwargs["extracted_text_content"])
- assert content_entries == [{"file_name": "data.csv", "content": [{"name": "Alice", "age": "30"}]}]
+ assert result.output_parameter_value == []
+ handler.assert_not_awaited()
record_output.assert_awaited_once()
+ assert record_output.await_args.args[2] == result.output_parameter_value
async def test_execute_local_path_outside_download_dir_fails(self, tmp_path: Path) -> None:
outside_path = tmp_path / "elsewhere" / "data.csv"