: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(llma): answer an unusable publish installation with 503, not 502 (#87121)
Andrew Maguire179d3e1c056a
diff --git a/docs/internal/skills/community-skills-api.md b/docs/internal/skills/community-skills-api.mdindex 348724dc86f5..febd16adecb3 100644--- a/docs/internal/skills/community-skills-api.md+++ b/docs/internal/skills/community-skills-api.md@@ -185,6 +185,11 @@ out of, so it must not read as GitHub being down.The three are kept apart on purpose, because each sends the publisher somewhere different. The skillis rendered before GitHub is touched, so a skill that has to be edited answers `400` even while the-App is down. `503` is reserved for an installation GitHub says is absent or refuses the App's-credentials for; any other failed status while minting the publish token is an outage and answers-`502`, so a transient failure doesn't read as "this instance can't publish".+App is down. `503` is reserved for the settings an operator has to change: an installation GitHub says+is absent, one whose App credentials it refuses, and one that doesn't grant the `contents` and+`pull_requests` write the mint asks for. Any other failed status while minting the publish token is an+outage and answers `502`, so a transient failure doesn't read as "this instance can't publish".++The 503 is logged as `llma_skill_publish_to_community_not_configured`, with the team, user and skill.+Without it an instance meant to have publishing on is indistinguishable from one that never+configured it, until somebody reports the toast.diff --git a/products/skills/backend/api/community_publish_services.py b/products/skills/backend/api/community_publish_services.pyindex d2c19b2ffddf..2d49cacc7d8c 100644--- a/products/skills/backend/api/community_publish_services.py+++ b/products/skills/backend/api/community_publish_services.py@@ -378,8 +378,9 @@ def _parent_directories(path: str) -> list[str]:PUBLISHER_TOKEN_PERMISSIONS = {"contents": "write", "pull_requests": "write", "metadata": "read"}# Statuses that mean the App isn't installed here or its credentials are rejected: unauthenticated,# not permitted, or no such installation. Rate limits never reach this set — the transport raises-# them, including the 403 spellings.-PUBLISHER_NOT_CONFIGURED_STATUSES = frozenset({401, 403, 404})+# them, including the 403 spellings. 422 joins them because GitHub answers a mint asking for+# permissions the installation does not grant that way, and only an admin can change that.+PUBLISHER_NOT_CONFIGURED_STATUSES = frozenset({401, 403, 404, 422})def _publisher_token_request_body() -> dict[str, Any]:diff --git a/products/skills/backend/api/skills.py b/products/skills/backend/api/skills.pyindex 12414988a1fa..7d33fec92726 100644--- a/products/skills/backend/api/skills.py+++ b/products/skills/backend/api/skills.py@@ -1069,6 +1069,14 @@ class LLMSkillViewSet(author_handle=payload.validated_data.get("author_handle", ""),)except CommunitySkillPublishNotConfiguredError:+ # The fail-safe is otherwise silent, so an instance that meant to have publishing on+ # looks like one that never configured it until somebody reports the toast.+ logger.warning(+ "llma_skill_publish_to_community_not_configured",+ team_id=self.team.id,+ user_id=cast(User, request.user).id,+ skill_name=skill.name,+ )return Response({"detail": "Publishing to the community is not available on this instance."},status=status.HTTP_503_SERVICE_UNAVAILABLE,diff --git a/products/skills/backend/api/test/test_community_publish_services.py b/products/skills/backend/api/test/test_community_publish_services.pyindex 29b6514ddebd..185367a0c678 100644--- a/products/skills/backend/api/test/test_community_publish_services.py+++ b/products/skills/backend/api/test/test_community_publish_services.py@@ -306,6 +306,7 @@ class TestCommunitySkillsPublisher:[("the app is not installed here", 404, False),("github refuses the app credentials", 401, False),+ ("the installation does not grant the permissions a publish needs", 422, False),("github fails the mint", 500, True),])