Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): always export App packages as version 2 (#45353)
-LAN-b98a13495323
diff --git a/api/services/app_package_service.py b/api/services/app_package_service.pyindex a1fda7d5758..aa92b3b09d8 100644--- a/api/services/app_package_service.py+++ b/api/services/app_package_service.py@@ -56,7 +56,7 @@ _AGENT_ID_KEY = "agent_id"class AppPackageManifest(BaseModel):"""Index Agent resources by the same package references used in the workflow DSL.- Version 2 also bundles the workflows the App calls through Workflow Tools; other packages stay version 1.+ Version 2 optionally bundles the workflows the App calls through Workflow Tools; version 1 remains readable."""model_config = ConfigDict(extra="ignore")@@ -76,6 +76,7 @@ class AppPackageManifest(BaseModel):@model_validator(mode="after")def validate_resource_paths(self) -> Self:+ """Return a manifest with unique resources, or reject duplicates and version 1 workflow tool bundles."""resources = [*self.iter_resources(), *self.workflow_tools]paths = [item.path.casefold() for item in [*self.apps, *resources]]ids = [item.id for item in resources]@@ -83,8 +84,8 @@ class AppPackageManifest(BaseModel):raise ValueError("App package resources must have unique paths and ids")if len({tool.provider_id for tool in self.workflow_tools}) != len(self.workflow_tools):raise ValueError("App package workflow tools must have unique provider ids")- if (self.format_version == 2) != bool(self.workflow_tools):- raise ValueError("App package format version 2 is used exactly when workflow tools are bundled")+ if self.format_version == 1 and self.workflow_tools:+ raise ValueError("App package workflow tools require format version 2")return self@@ -525,6 +526,10 @@ class AppPackageService(RosterAgentPackageReader):accept_roster_references: bool = False,workflow_tools: Sequence[_WorkflowToolExport],) -> RosterAgentPackageExport:+ """Return a validated version 2 archive for an App DSL and its resources.++ Reject invalid content or exceeded import limits; close the output archive on failure.+ """payload = dsl.encode("utf-8")if len(payload) > DSL_MAX_SIZE:raise RosterAgentPackageTooLargeError("App package DSL exceeds the size limit")@@ -539,7 +544,7 @@ class AppPackageService(RosterAgentPackageReader):]manifest = AppPackageManifest(format="dify.app",- format_version=2 if packaged_tools else 1,+ format_version=2,apps=[RosterAgentPackageApp(path="app.yaml", size=len(payload), sha256=hashlib.sha256(payload).hexdigest()diff --git a/api/tests/unit_tests/services/app/test_console_service.py b/api/tests/unit_tests/services/app/test_console_service.pyindex 2b89ba73883..5feb295e166 100644--- a/api/tests/unit_tests/services/app/test_console_service.py+++ b/api/tests/unit_tests/services/app/test_console_service.py@@ -1299,6 +1299,7 @@ def test_export_bundles_the_pinned_workflow_and_its_tool_definition(["productivity"],)with ZipFile(archive.open(tool["path"])) as nested:+ assert yaml.safe_load(nested.read("manifest.yaml"))["format_version"] == 2assert yaml.safe_load(nested.read("app.yaml"))["app"]["name"] == "Summarizer"@@ -1331,6 +1332,7 @@ def test_export_bundles_only_workflows_the_caller_may_export(with exported, ZipFile(exported.archive) as archive:manifest = yaml.safe_load(archive.read("manifest.yaml"))dsl = yaml.safe_load(archive.read("app.yaml"))+ assert manifest["format_version"] == 2assert [tool["provider_id"] for tool in manifest.get("workflow_tools", [])] == ([workspaces.provider_id] if bundled else [])diff --git a/api/tests/unit_tests/services/test_app_package_service.py b/api/tests/unit_tests/services/test_app_package_service.pyindex 28ee7d818b1..dcf5dce4666 100644--- a/api/tests/unit_tests/services/test_app_package_service.py+++ b/api/tests/unit_tests/services/test_app_package_service.py@@ -847,6 +847,9 @@ class TestAppPackageServiceCases:service = AppPackageService()with service.export(dsl=dsl, name="Example App", workflow_tools=[]) as package:assert package.filename == "example-app.ifpkg"+ _, manifest = _read_export(package.archive.read())+ assert manifest["format_version"] == 2+ package.archive.seek(0)prepared = service.read_package(package.archive)assert prepared is not Nonewith prepared:@@ -855,7 +858,16 @@ class TestAppPackageServiceCases:assert package.archive.closed@staticmethod- @pytest.mark.parametrize("overrides", [{"format": "unknown"}, {"format_version": 2}, {"apps": []}])+ @pytest.mark.parametrize("format_version", [1, 2])+ def test_reads_packages_without_workflow_tools(format_version: int) -> None:+ prepared = AppPackageService().read_package(_archive(_FOLDER_DSL, format_version=format_version))+ assert prepared is not None+ with prepared:+ assert prepared.dsl == _FOLDER_DSL+ assert prepared.workflow_tools == []++ @staticmethod+ @pytest.mark.parametrize("overrides", [{"format": "unknown"}, {"format_version": 3}, {"apps": []}])def test_rejects_unsupported_manifests(overrides: dict[str, object]) -> None:with pytest.raises(InvalidRosterAgentPackageError, match="manifest"):AppPackageService().read_package(_archive("kind: app\napp: {mode: workflow}\n", **overrides))