Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(skills): say which spec rule blocks a skill download or import (#95341)

Andrew Maguire6a693c1b1b2e
diff --git a/products/skills/backend/api/skills.py b/products/skills/backend/api/skills.py
index 1282b81ea756..2a96e8aa5ee1 100644
--- a/products/skills/backend/api/skills.py
+++ b/products/skills/backend/api/skills.py
@@ -321,6 +321,12 @@ class ZipRenderer(BaseRenderer):
return SafeJSONRenderer().render(data, "application/json", renderer_context)
+def _spec_problems_detail(lead: str, problems: list[str], next_step: str) -> str:
+ # Clients such as the app toast show only `detail`, so the specific problems must live there too.
+ sentences = ". ".join((problem[:1].upper() + problem[1:]).removesuffix(".") for problem in problems)
+ return f"{lead} {sentences}. {next_step}"
+
+
_ZIP_ACTIONS = ("bundle", "export")
# With two renderers on an action, drf-spectacular advertises DRF's ``?format=`` override as a query
# parameter. Clients select the zip with ``Accept``; keep the generated types free of it.
@@ -809,7 +815,14 @@ class LLMSkillViewSet(
problems = validate_for_export(export)
if problems:
return Response(
- {"detail": "Skill is not export-ready under the Agent Skills spec.", "problems": problems},
+ {
+ "detail": _spec_problems_detail(
+ "Couldn't download this skill because it doesn't meet the Agent Skills spec.",
+ problems,
+ "Edit the skill to fix this, then try again.",
+ ),
+ "problems": problems,
+ },
status=status.HTTP_400_BAD_REQUEST,
)
@@ -905,7 +918,14 @@ class LLMSkillViewSet(
problems = self._import_problems(skill_export)
if problems:
return Response(
- {"detail": "Zip is not a valid, spec-compliant skill.", "problems": problems},
+ {
+ "detail": _spec_problems_detail(
+ "Couldn't import this zip because it doesn't meet the Agent Skills spec.",
+ problems,
+ "Fix the skill files, then try again.",
+ ),
+ "problems": problems,
+ },
status=status.HTTP_400_BAD_REQUEST,
)
diff --git a/products/skills/backend/api/test/test_marketplace_endpoints.py b/products/skills/backend/api/test/test_marketplace_endpoints.py
index 450fdf9efc6e..85609ee98f17 100644
--- a/products/skills/backend/api/test/test_marketplace_endpoints.py
+++ b/products/skills/backend/api/test/test_marketplace_endpoints.py
@@ -166,7 +166,9 @@ class TestSkillZipExport(APIBaseTest):
)
response = self.client.get(self._url("too-long"))
assert response.status_code == status.HTTP_400_BAD_REQUEST
- assert response.json()["problems"]
+ body = response.json()
+ assert body["problems"]
+ assert "Description is 1025 characters; the spec maximum is 1024" in body["detail"]
SANDBOX_FLAG = "posthog.permissions.posthoganalytics.feature_enabled"