: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(file-system): resolve access levels when shortcuts serialize a queryset (#108181)
posthog[bot]68415438d688
diff --git a/posthog/api/file_system/access_levels.py b/posthog/api/file_system/access_levels.pyindex 59560f8f9208..3453ccc62070 100644--- a/posthog/api/file_system/access_levels.py+++ b/posthog/api/file_system/access_levels.py@@ -439,7 +439,8 @@ class FileSystemAccessLevelSerializerMixin(serializers.Serializer):return Noneif self._access_levels_by_type_ref is None:- instances = self.instance if isinstance(self.instance, list) else [self.instance]+ # With many=True, DRF gives each child the full collection: a list or a QuerySet+ instances = self.instance if isinstance(self.instance, Iterable) else [self.instance]entries = [FileSystemAccessEntry(entry_type=instance.type,diff --git a/posthog/api/file_system/test/test_file_system_shortcut.py b/posthog/api/file_system/test/test_file_system_shortcut.pyindex ac8e2de6c7fb..20244446ed26 100644--- a/posthog/api/file_system/test/test_file_system_shortcut.py+++ b/posthog/api/file_system/test/test_file_system_shortcut.py@@ -320,3 +320,25 @@ class TestFileSystemShortcutAccessLevels(APIBaseTest):self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())levels = {item["path"]: item["user_access_level"] for item in response.json()["results"]}self.assertEqual(levels, {"Real": "none", "Guessed": "none"})++ @parameterized.expand(+ [+ ("bulk_update", lambda shortcut: {"add": [], "remove_ids": []}),+ ("reorder", lambda shortcut: {"ordered_ids": [str(shortcut.id)]}),+ ]+ )+ def test_write_endpoints_return_access_levels(self, url_path, build_payload):+ theirs = Dashboard.objects.create(team=self.team, name="Theirs", created_by=self.other_user)+ shortcut = FileSystemShortcut.objects.create(+ team=self.team, user=self.user, path="Theirs", type="dashboard", ref=str(theirs.pk)+ )+ AccessControl.objects.create(team=self.team, resource="dashboard", resource_id=None, access_level="none")++ response = self.client.post(+ f"/api/projects/{self.team.id}/file_system_shortcut/{url_path}/",+ build_payload(shortcut),+ format="json",+ )++ self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())+ self.assertEqual([item["user_access_level"] for item in response.json()], ["none"])