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
fix(skills): tolerate __MACOSX metadata folder when importing a Skill package (#41757)
Jialong(Bruce) Li95aeb0c3624c
diff --git a/api/services/skill_management_service.py b/api/services/skill_management_service.pyindex 92d3de2f2ea..4d4c4299b79 100644--- a/api/services/skill_management_service.py+++ b/api/services/skill_management_service.py@@ -3747,14 +3747,22 @@ class SkillManagementService:@staticmethoddef _strip_single_root(paths: list[str]) -> dict[str, str]:- if not paths:- return {}- first_segments = {path.split("/", 1)[0] for path in paths if "/" in path}- root = next(iter(first_segments)) if len(first_segments) == 1 else None- if root is None or f"{root}/{_SKILL_MD}" not in paths or _SKILL_MD in paths:+ if not paths or _SKILL_MD in paths:+ return {path: path for path in paths}+ # Identify the root by the unique top-level `<root>/SKILL.md`, rather than+ # requiring every path to share one first segment: tools like macOS Finder's+ # "Compress" add a sibling `__MACOSX/` metadata folder that must not defeat+ # stripping of the real skill folder. Entries outside the detected root+ # (like `__MACOSX/...`) are dropped rather than passed through, matching+ # skill_package_service._normalize_members(ignore_outside_selected_root=True).+ skill_md_roots = {+ path.split("/", 1)[0] for path in paths if path.count("/") == 1 and path.endswith(f"/{_SKILL_MD}")+ }+ if len(skill_md_roots) != 1:return {path: path for path in paths}- stripped = {path: path.removeprefix(f"{root}/") for path in paths}- return stripped+ root = next(iter(skill_md_roots))+ prefix = f"{root}/"+ return {path: path.removeprefix(prefix) for path in paths if path == root or path.startswith(prefix)}def _draft_payload_from_zip(self,@@ -3775,6 +3783,8 @@ class SkillManagementService:skill_md_content = ""for info in infos:raw_path = normalize_skill_file_path(info.filename.strip("/"))+ if raw_path not in path_map:+ continuepath = normalize_skill_file_path(path_map[raw_path])if info.is_dir():items.append(SkillDraftTreeItemPayload(path=path, kind=SkillFileKind.DIRECTORY))diff --git a/api/tests/unit_tests/services/test_skill_management_service.py b/api/tests/unit_tests/services/test_skill_management_service.pyindex 8e9fd12529b..62807577ed0 100644--- a/api/tests/unit_tests/services/test_skill_management_service.py+++ b/api/tests/unit_tests/services/test_skill_management_service.py@@ -2664,6 +2664,32 @@ def test_import_skill_package_creates_draft_and_rejects_name_conflicts() -> Noneassert exc_info.value.code == "skill_name_conflict"+def test_import_skill_package_strips_root_alongside_macos_metadata_folder() -> None:+ package = io.BytesIO()+ with zipfile.ZipFile(package, "w") as archive:+ archive.writestr(+ "expense-sop/SKILL.md",+ "---\nname: expense-sop\ndescription: Expenses\n---\n# Expenses",+ )+ archive.writestr("expense-sop/references/policy.md", "Policy")+ # macOS Finder "Compress" adds an AppleDouble metadata sibling folder+ # for archives whose source files carry extended attributes.+ archive.writestr("__MACOSX/expense-sop/._SKILL.md", b"\x00")++ service = SkillManagementService(tool_file_manager=_FakeToolFileManager())+ imported = service.import_skill(+ tenant_id=TENANT,+ user_id=USER,+ payload=SkillImportPayload(content=package.getvalue(), filename="expense-sop.zip"),+ )++ assert imported["name"] == "expense-sop"+ imported_paths = [item["path"] for item in imported["files"]]+ assert "SKILL.md" in imported_paths+ assert "references/policy.md" in imported_paths+ assert not any(path.startswith("__MACOSX") for path in imported_paths)++def test_import_skill_package_rejects_missing_frontmatter_description() -> None:package = io.BytesIO()with zipfile.ZipFile(package, "w") as archive: