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.

chore: stop accepting collaborator-only dashboards in the API (#111119)

Reece Jones5b66ee5b73df
diff --git a/ee/api/test/test_insight.py b/ee/api/test/test_insight.py
index ab785afcda60..662917386daf 100644
--- a/ee/api/test/test_insight.py
+++ b/ee/api/test/test_insight.py
@@ -375,9 +375,12 @@ class TestInsightEnterpriseAPI(APILicensedTest):
self._require_access_control()
self._set_project_default_member_access()
# create insight and dashboard separately with default user
- dashboard_restricted_id, _ = self.dashboard_api.create_dashboard(
- {"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT}
+ dashboard_restricted = Dashboard.objects.create(
+ team=self.team,
+ created_by=self.user,
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
)
+ dashboard_restricted_id = dashboard_restricted.id
insight_id, response_data = self.dashboard_api.create_insight(data={"name": "starts un-restricted dashboard"})
@@ -408,9 +411,12 @@ class TestInsightEnterpriseAPI(APILicensedTest):
) -> None:
self._require_access_control()
self._set_project_default_member_access()
- dashboard_restricted_id, _ = self.dashboard_api.create_dashboard(
- {"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT}
+ dashboard_restricted = Dashboard.objects.create(
+ team=self.team,
+ created_by=self.user,
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
)
+ dashboard_restricted_id = dashboard_restricted.id
user_without_permissions = User.objects.create_and_join(
organization=self.organization,
@@ -430,9 +436,12 @@ class TestInsightEnterpriseAPI(APILicensedTest):
def test_admin_user_can_create_an_insight_on_a_restricted_dashboard(self) -> None:
self._require_access_control()
self._set_project_default_member_access()
- dashboard_restricted_id, _ = self.dashboard_api.create_dashboard(
- {"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT}
+ dashboard_restricted = Dashboard.objects.create(
+ team=self.team,
+ created_by=self.user,
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
)
+ dashboard_restricted_id = dashboard_restricted.id
self.client.force_login(self.user)
self.dashboard_api.create_insight(
@@ -621,9 +630,12 @@ class TestInsightEnterpriseAPI(APILicensedTest):
self._require_access_control()
self._set_project_default_member_access()
# create a restricted dashboard with the default user (who has edit permission)
- dashboard_restricted_id, _ = self.dashboard_api.create_dashboard(
- {"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT}
+ dashboard_restricted = Dashboard.objects.create(
+ team=self.team,
+ created_by=self.user,
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
)
+ dashboard_restricted_id = dashboard_restricted.id
# create an insight on that dashboard
insight_id, _ = self.dashboard_api.create_insight(
diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.py
index b4e6e5a81376..6334c454de4c 100644
--- a/posthog/api/test/dashboards/test_dashboard.py
+++ b/posthog/api/test/dashboards/test_dashboard.py
@@ -685,6 +685,32 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):
instance = Dashboard.objects.get(id=response_data["id"])
self.assertEqual(instance.name, "My new dashboard")
+ @parameterized.expand([("create",), ("update",)])
+ def test_reject_legacy_collaborator_restriction_on_write(self, operation: str) -> None:
+ self.organization.available_product_features = []
+ self.organization.save()
+
+ if operation == "create":
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/dashboards/",
+ {
+ "name": "legacy dashboard",
+ "restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
+ },
+ )
+ self.assertFalse(Dashboard.objects.filter(name="legacy dashboard").exists())
+ else:
+ dashboard = Dashboard.objects.create(team=self.team, name="dashboard", created_by=self.user)
+ response = self.client.patch(
+ f"/api/projects/{self.team.id}/dashboards/{dashboard.id}",
+ {"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT},
+ )
+ dashboard.refresh_from_db()
+ self.assertEqual(dashboard.restriction_level, Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT)
+
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertEqual(response.json()["attr"], "restriction_level")
+
def test_update_dashboard(self):
dashboard = Dashboard.objects.create(
team=self.team,
@@ -711,6 +737,15 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):
dashboard.refresh_from_db()
self.assertEqual(dashboard.name, "dashboard new name")
+ def test_update_dashboard_last_refresh(self) -> None:
+ dashboard = Dashboard.objects.create(team=self.team, name="dashboard", created_by=self.user)
+ last_refresh = now().replace(microsecond=0)
+
+ self.dashboard_api.update_dashboard(dashboard.pk, {"last_refresh": last_refresh.isoformat()})
+
+ dashboard.refresh_from_db()
+ self.assertEqual(dashboard.last_refresh, last_refresh)
+
def test_dashboard_tile_spacing_is_saved_and_duplicated(self):
dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "dashboard"})
diff --git a/posthog/management/commands/migrate_dashboard_collaborators.py b/posthog/management/commands/migrate_dashboard_collaborators.py
new file mode 100644
index 000000000000..2c10073d458f
--- /dev/null
+++ b/posthog/management/commands/migrate_dashboard_collaborators.py
@@ -0,0 +1,65 @@
+import argparse
+from typing import Any
+from uuid import UUID
+
+from django.core.management.base import BaseCommand, CommandError
+
+from posthog.rbac.migrations.rbac_dashboard_migration import rbac_dashboard_access_control_migration
+
+from products.dashboards.backend.models.dashboard import Dashboard
+
+
+class Command(BaseCommand):
+ help = "Migrate legacy dashboard collaborator access to access control"
+
+ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
+ parser.add_argument(
+ "--org-ids",
+ type=str,
+ help="Comma-separated organization UUIDs to limit the migration. Omit to process all eligible organizations.",
+ )
+ parser.add_argument(
+ "--dry-run",
+ action="store_true",
+ help="Show the dashboards that would be migrated without making changes.",
+ )
+
+ def handle(self, *args: Any, **options: Any) -> None:
+ dashboards = Dashboard.objects.filter(restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT)
+ org_ids_input = options.get("org_ids")
+ if org_ids_input is not None:
+ try:
+ requested_org_ids = {UUID(org_id.strip()) for org_id in org_ids_input.split(",") if org_id.strip()}
+ except ValueError as error:
+ raise CommandError("--org-ids must be a comma-separated list of organization UUIDs.") from error
+ if not requested_org_ids:
+ raise CommandError("--org-ids must include at least one organization UUID.")
+ dashboards = dashboards.filter(team__organization_id__in=requested_org_ids)
+
+ dashboard_count = dashboards.count()
+ organization_ids = list(
+ dashboards.values_list("team__organization_id", flat=True).distinct().order_by("team__organization_id")
+ )
+ organization_count = len(organization_ids)
+
+ if dashboard_count == 0:
+ self.stdout.write("No dashboards need collaborator migration.")
+ return
+
+ dashboard_label = "dashboard" if dashboard_count == 1 else "dashboards"
+ organization_label = "organization" if organization_count == 1 else "organizations"
+ if options.get("dry_run"):
+ self.stdout.write(
+ f"Would migrate {dashboard_count} {dashboard_label} across {organization_count} {organization_label}."
+ )
+ return
+
+ for organization_id in organization_ids:
+ rbac_dashboard_access_control_migration(organization_id)
+
+ self.stdout.write(
+ self.style.SUCCESS(
+ f"Migrated collaborator access for {dashboard_count} {dashboard_label} "
+ f"across {organization_count} {organization_label}."
+ )
+ )
diff --git a/posthog/management/commands/test/test_migrate_dashboard_collaborators.py b/posthog/management/commands/test/test_migrate_dashboard_collaborators.py
new file mode 100644
index 000000000000..88a7eac335a2
--- /dev/null
+++ b/posthog/management/commands/test/test_migrate_dashboard_collaborators.py
@@ -0,0 +1,36 @@
+from io import StringIO
+
+from posthog.test.base import BaseTest
+
+from django.core.management import call_command
+
+from products.access_control.backend.models.access_control import AccessControl
+from products.dashboards.backend.models.dashboard import Dashboard
+
+
+class TestMigrateDashboardCollaborators(BaseTest):
+ def test_dry_run_and_rerun_are_safe(self) -> None:
+ dashboard = Dashboard.objects.create(
+ team=self.team,
+ name="Restricted dashboard",
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
+ )
+ args = [f"--org-ids={self.organization.id}"]
+ dry_run_output = StringIO()
+
+ call_command("migrate_dashboard_collaborators", *args, "--dry-run", stdout=dry_run_output)
+
+ dashboard.refresh_from_db()
+ assert dashboard.restriction_level == Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT
+ assert not AccessControl.objects.filter(resource="dashboard", resource_id=str(dashboard.id)).exists()
+ assert "Would migrate 1 dashboard across 1 organization." in dry_run_output.getvalue()
+
+ call_command("migrate_dashboard_collaborators", *args)
+ dashboard.refresh_from_db()
+ assert dashboard.restriction_level == Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT
+ access_controls = AccessControl.objects.filter(resource="dashboard", resource_id=str(dashboard.id))
+ assert access_controls.count() == 1
+ assert access_controls.get().access_level == "viewer"
+
+ call_command("migrate_dashboard_collaborators", *args, stdout=StringIO())
+ assert access_controls.count() == 1
diff --git a/posthog/rbac/migrations/rbac_dashboard_migration.py b/posthog/rbac/migrations/rbac_dashboard_migration.py
index 8ce0c8861ce5..ca4160d2c7f2 100644
--- a/posthog/rbac/migrations/rbac_dashboard_migration.py
+++ b/posthog/rbac/migrations/rbac_dashboard_migration.py
@@ -1,17 +1,83 @@
+from typing import Literal
+
from django.db import transaction
+from django.db.models import Q
import structlog
+from posthog.constants import AvailableFeature
from posthog.exceptions_capture import capture_exception
from posthog.models.organization import Organization, OrganizationMembership
+from products.access_control.backend.facade.user_access_control import ordered_access_levels
from products.access_control.backend.models.access_control import AccessControl
+from products.access_control.backend.models.role import RoleMembership
from products.dashboards.backend.models.dashboard import Dashboard
logger = structlog.get_logger(__name__)
-def rbac_dashboard_access_control_migration(organization_id: int):
+def _has_dashboard_role_access(
+ dashboard: Dashboard,
+ organization: Organization,
+ user_id: int,
+) -> bool:
+ if not organization.is_feature_available(AvailableFeature.ROLE_BASED_ACCESS):
+ return False
+
+ role_ids = (
+ RoleMembership.objects.filter(user_id=user_id, role__organization_id=organization.id)
+ .valid_for_authorization()
+ .values("role_id")
+ )
+ return (
+ AccessControl.objects.filter(
+ team_id=dashboard.team_id,
+ resource="dashboard",
+ organization_member__isnull=True,
+ role_id__in=role_ids,
+ )
+ .filter(Q(resource_id=str(dashboard.id)) | Q(resource_id__isnull=True))
+ .exists()
+ )
+
+
+def _ensure_dashboard_access_control(
+ dashboard: Dashboard,
+ organization_member: OrganizationMembership | None,
+ access_level: Literal["viewer", "editor"],
+) -> None:
+ access_control = AccessControl.objects.filter(
+ team_id=dashboard.team_id,
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ organization_member=organization_member,
+ role__isnull=True,
+ ).first()
+ if access_control is None:
+ AccessControl.objects.create(
+ team_id=dashboard.team_id,
+ access_level=access_level,
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ organization_member=organization_member,
+ )
+ return
+
+ if access_control.access_level in ordered_access_levels("dashboard"):
+ return
+
+ logger.warning(
+ "Replacing invalid dashboard access level during migration",
+ access_control_id=access_control.id,
+ invalid_access_level=access_control.access_level,
+ replacement_access_level=access_level,
+ )
+ access_control.access_level = access_level
+ access_control.save(update_fields=["access_level"])
+
+
+def rbac_dashboard_access_control_migration(organization_id: int) -> None:
"""
This migration converts legacy dashboard permissions to the new RBAC system.
@@ -37,29 +103,10 @@ def rbac_dashboard_access_control_migration(organization_id: int):
for dashboard in restricted_dashboards:
try:
- # Skip if access control already exists for this dashboard
- if AccessControl.objects.filter(
- team_id=dashboard.team_id,
- resource="dashboard",
- resource_id=str(dashboard.id),
- ).exists():
- logger.info(
- "Skipping dashboard - access control already exists",
- dashboard_id=dashboard.id,
- team_id=dashboard.team_id,
- )
- continue
-
- # Create default access control entry for the dashboard (view access for all)
- AccessControl.objects.create(
- team_id=dashboard.team_id,
+ _ensure_dashboard_access_control(
+ dashboard,
+ organization_member=None,
access_level="viewer",
- resource="dashboard",
- resource_id=str(dashboard.id),
- )
-
- logger.info(
- "Created default dashboard access control", dashboard_id=dashboard.id, team_id=dashboard.team_id
)
# Convert dashboard privileges to access control entries
@@ -83,15 +130,20 @@ def rbac_dashboard_access_control_migration(organization_id: int):
)
continue
- # Create access control entry for the user with edit access
- AccessControl.objects.create(
- team_id=dashboard.team_id,
- access_level="editor",
- resource="dashboard",
- resource_id=str(dashboard.id),
- organization_member=org_membership,
- )
+ if _has_dashboard_role_access(dashboard, organization, privilege.user_id):
+ logger.info(
+ "Preserving role-based dashboard access for collaborator",
+ dashboard_id=dashboard.id,
+ user_id=privilege.user_id,
+ )
+ else:
+ _ensure_dashboard_access_control(
+ dashboard,
+ organization_member=org_membership,
+ access_level="editor",
+ )
+ privilege.delete()
logger.info(
"Migrated dashboard privilege to access control",
dashboard_id=dashboard.id,
@@ -99,9 +151,6 @@ def rbac_dashboard_access_control_migration(organization_id: int):
team_id=dashboard.team_id,
)
- # Remove the original privilege entry
- privilege.delete()
-
except Exception as e:
error_message = f"Failed to migrate dashboard privilege for user {privilege.user.id}"
logger.exception(error_message, exc_info=e)
diff --git a/posthog/rbac/migrations/test/test_rbac_dashboard_migration.py b/posthog/rbac/migrations/test/test_rbac_dashboard_migration.py
index a7764b2b0bf4..19affbc02e7e 100644
--- a/posthog/rbac/migrations/test/test_rbac_dashboard_migration.py
+++ b/posthog/rbac/migrations/test/test_rbac_dashboard_migration.py
@@ -1,13 +1,17 @@
import pytest
from posthog.test.base import BaseTest
+from parameterized import parameterized
+
from posthog.constants import AvailableFeature
from posthog.models.organization import Organization, OrganizationMembership
from posthog.models.team.team import Team
from posthog.models.user import User
from posthog.rbac.migrations.rbac_dashboard_migration import rbac_dashboard_access_control_migration
+from products.access_control.backend.facade.user_access_control import UserAccessControl
from products.access_control.backend.models.access_control import AccessControl
+from products.access_control.backend.models.role import Role, RoleMembership
from products.dashboards.backend.models.dashboard import Dashboard
from ee.models.dashboard_privilege import DashboardPrivilege
@@ -190,49 +194,139 @@ class TestRBACDashboardMigration(BaseTest):
orphaned_privilege_count = DashboardPrivilege.objects.filter(user=orphaned_user).count()
self.assertEqual(orphaned_privilege_count, 1) # Should still exist
- def test_migration_skips_dashboards_with_existing_access_control(self):
- """Test that migration skips dashboards that already have access control entries"""
- # Create a dashboard with restriction level 37
+ def test_migration_completes_when_access_control_already_exists(self):
dashboard = Dashboard.objects.create(
team=self.team,
name="Dashboard with Existing Access Control",
restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
)
-
- # Create existing access control
existing_ac = AccessControl.objects.create(
team_id=self.team.id,
- access_level="admin",
+ access_level="manager",
resource="dashboard",
resource_id=str(dashboard.id),
organization_member=self.user1_membership,
)
-
- # Create a dashboard privilege that should not be migrated
+ default_ac = AccessControl.objects.create(
+ team_id=self.team.id,
+ access_level="invalid",
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ )
+ member_ac = AccessControl.objects.create(
+ team_id=self.team.id,
+ access_level="invalid",
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ organization_member=self.user2_membership,
+ )
DashboardPrivilege.objects.create(
dashboard=dashboard,
user=self.user2,
level=Dashboard.PrivilegeLevel.CAN_EDIT,
)
- # Run migration
rbac_dashboard_access_control_migration(self.organization.id)
- # Reload dashboard from database
dashboard.refresh_from_db()
+ self.assertEqual(dashboard.restriction_level, Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT)
+ self.assertEqual(AccessControl.objects.filter(resource="dashboard", resource_id=str(dashboard.id)).count(), 3)
+ default_ac.refresh_from_db()
+ self.assertEqual(default_ac.access_level, "viewer")
+ member_ac.refresh_from_db()
+ self.assertEqual(member_ac.access_level, "editor")
+ self.assertTrue(AccessControl.objects.filter(id=existing_ac.id).exists())
+ self.assertFalse(DashboardPrivilege.objects.filter(dashboard=dashboard).exists())
- # Verify dashboard restriction level was NOT updated
- self.assertEqual(dashboard.restriction_level, Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT)
+ rbac_dashboard_access_control_migration(self.organization.id)
- # Verify only the existing access control remains
- access_controls = AccessControl.objects.filter(resource="dashboard", resource_id=str(dashboard.id))
- self.assertEqual(access_controls.count(), 1)
- remaining_ac = access_controls.first()
- assert remaining_ac is not None
- self.assertEqual(remaining_ac.id, existing_ac.id)
+ self.assertEqual(AccessControl.objects.filter(resource="dashboard", resource_id=str(dashboard.id)).count(), 3)
- # Verify dashboard privilege was not deleted
- self.assertEqual(DashboardPrivilege.objects.filter(dashboard=dashboard).count(), 1)
+ def test_migration_preserves_existing_access_control_denials_and_viewers(self):
+ dashboard = Dashboard.objects.create(
+ team=self.team,
+ name="Dashboard with existing restrictions",
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
+ )
+ default_access = AccessControl.objects.create(
+ team_id=self.team.id,
+ access_level="none",
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ )
+ member_access = AccessControl.objects.create(
+ team_id=self.team.id,
+ access_level="viewer",
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ organization_member=self.user2_membership,
+ )
+ DashboardPrivilege.objects.create(
+ dashboard=dashboard,
+ user=self.user2,
+ level=Dashboard.PrivilegeLevel.CAN_EDIT,
+ )
+
+ rbac_dashboard_access_control_migration(self.organization.id)
+
+ dashboard.refresh_from_db()
+ default_access.refresh_from_db()
+ member_access.refresh_from_db()
+ self.assertEqual(dashboard.restriction_level, Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT)
+ self.assertEqual(default_access.access_level, "none")
+ self.assertEqual(member_access.access_level, "viewer")
+ self.assertFalse(DashboardPrivilege.objects.filter(dashboard=dashboard).exists())
+
+ @parameterized.expand([("viewer",), ("none",)])
+ def test_migration_preserves_role_based_dashboard_access(self, role_access_level: str) -> None:
+ self.organization.available_product_features = (self.organization.available_product_features or []) + [
+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS}
+ ]
+ self.organization.save()
+ role = Role.objects.create(name="Dashboard viewers", organization=self.organization)
+ RoleMembership.objects.create(
+ role=role,
+ user=self.user2,
+ organization_member=self.user2_membership,
+ )
+ dashboard = Dashboard.objects.create(
+ team=self.team,
+ name="Dashboard with role access",
+ restriction_level=Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT,
+ )
+ AccessControl.objects.create(
+ team_id=self.team.id,
+ access_level=role_access_level,
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ role=role,
+ )
+ DashboardPrivilege.objects.create(
+ dashboard=dashboard,
+ user=self.user2,
+ level=Dashboard.PrivilegeLevel.CAN_EDIT,
+ )
+
+ rbac_dashboard_access_control_migration(self.organization.id)
+
+ dashboard.refresh_from_db()
+ self.assertEqual(dashboard.restriction_level, Dashboard.RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT)
+ self.assertFalse(
+ AccessControl.objects.filter(
+ team_id=self.team.id,
+ resource="dashboard",
+ resource_id=str(dashboard.id),
+ organization_member=self.user2_membership,
+ role=None,
+ ).exists()
+ )
+ self.assertFalse(DashboardPrivilege.objects.filter(dashboard=dashboard).exists())
+ user_access = UserAccessControl(user=self.user2, team=self.team)
+ self.assertFalse(user_access.check_access_level_for_object(dashboard, "editor"))
+ self.assertEqual(
+ user_access.check_access_level_for_object(dashboard, "viewer"),
+ role_access_level == "viewer",
+ )
def test_migration_handles_multiple_teams_in_organization(self):
"""Test that migration works correctly with multiple teams in the organization"""
diff --git a/posthog/test/repo_invariants/test_serializer_timestamp_guard.py b/posthog/test/repo_invariants/test_serializer_timestamp_guard.py
index 79d962165ca5..42b8c3c3b3d9 100644
--- a/posthog/test/repo_invariants/test_serializer_timestamp_guard.py
+++ b/posthog/test/repo_invariants/test_serializer_timestamp_guard.py
@@ -116,8 +116,8 @@ REVIEWED_WRITABLE: dict[str, str] = {
"products.conversations.backend.api.tickets.TicketSerializer.snoozed_until": "Client-set instant: the ticket action assigns validated_data['snoozed_until'] to ticket.snoozed_until, with no relative-duration parsing on this path",
"products.conversations.backend.api.tickets.TicketUpdateRequestSerializer.sla_due_at": "Client or a workflow sets the SLA deadline, and null clears it",
"products.conversations.backend.api.tickets.TicketUpdateRequestSerializer.snoozed_until": "Client-set instant: the ticket action assigns validated_data['snoozed_until'] to ticket.snoozed_until, with no relative-duration parsing on this path",
- "products.dashboards.backend.api.dashboard.DashboardSerializer.last_accessed_at": "TODO: server-owned, written when a dashboard is opened",
- "products.dashboards.backend.api.dashboard.DashboardSerializer.last_refresh": "TODO: server-owned, written by the dashboard refresh path",
+ "products.dashboards.backend.api.dashboard.DashboardSerializer.last_refresh": "The frontend PATCHes successful forced-refresh completion so reopening the dashboard retains its shared cooldown",
+ "products.dashboards.backend.api.dashboard.DashboardWriteOpenApiSerializer.last_refresh": "The frontend persists successful forced-refresh completion so reopening the dashboard retains its shared cooldown",
"products.experiments.backend.presentation.serializers.ExperimentSerializer.end_date": "Client stops the experiment by setting this",
"products.experiments.backend.presentation.serializers.ExperimentSerializer.start_date": "Client launches the experiment by setting this",
"products.experiments.backend.presentation.serializers.ExperimentWriteSerializer.end_date": "Client stops the experiment by setting this",
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index a5c233f67907..cdefa434627b 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -1237,7 +1237,12 @@ class DashboardBasicSerializer(
"name": {"help_text": "Name of the dashboard."},
"description": {"help_text": "Description of the dashboard."},
"pinned": {"help_text": "Whether the dashboard is pinned to the top of the list."},
- "restriction_level": {"help_text": "Controls who can edit the dashboard."},
+ "restriction_level": {
+ "help_text": (
+ "Only restriction level 21 is accepted on create and update. "
+ "Legacy value 37 is deprecated and rejected."
+ )
+ },
}
@extend_schema_field(serializers.ChoiceField(choices=RestrictionLevel.choices))
@@ -1331,6 +1336,13 @@ class DashboardMetadataSerializer(DashboardBasicSerializer):
effective_privilege_level = serializers.SerializerMethodField()
effective_restriction_level = serializers.SerializerMethodField()
access_control_version = serializers.SerializerMethodField()
+ restriction_level = serializers.ChoiceField(
+ choices=RestrictionLevel.choices,
+ required=False,
+ help_text=(
+ "Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected."
+ ),
+ )
is_shared = serializers.BooleanField(source="is_sharing_enabled", read_only=True, required=False)
breakdown_colors = BreakdownColorsField(
child=BreakdownColorConfigSerializer(),
@@ -1372,7 +1384,20 @@ class DashboardMetadataSerializer(DashboardBasicSerializer):
class Meta:
model = Dashboard
fields = DASHBOARD_SHARED_FIELDS
- read_only_fields = ["creation_mode", "effective_restriction_level", "is_shared", "user_access_level"]
+ read_only_fields = [
+ "creation_mode",
+ "effective_restriction_level",
+ "is_shared",
+ "user_access_level",
+ "last_accessed_at",
+ ]
+
+ def validate_restriction_level(self, value: int) -> int:
+ if value == RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT:
+ raise serializers.ValidationError(
+ "Collaborator-only dashboard access is no longer supported. Set the restriction level to 21."
+ )
+ return value
def get_filters(self, dashboard: Dashboard) -> dict:
request = self.context.get("request")
@@ -1621,7 +1646,13 @@ class DashboardSerializer(DashboardMetadataSerializer):
"delete_insights",
"_create_in_folder",
]
- read_only_fields = ["creation_mode", "effective_restriction_level", "is_shared", "user_access_level"]
+ read_only_fields = [
+ "creation_mode",
+ "effective_restriction_level",
+ "is_shared",
+ "user_access_level",
+ "last_accessed_at",
+ ]
def validate_variables(self, value) -> dict:
if not isinstance(value, dict):
@@ -2539,6 +2570,18 @@ class DashboardSerializer(DashboardMetadataSerializer):
return {**validated_data, "creation_mode": "default"}
+class DashboardWriteOpenApiSerializer(DashboardSerializer):
+ # Existing dashboards may return 37, but write requests must not accept it.
+ restriction_level = serializers.IntegerField( # type: ignore[assignment]
+ min_value=RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT.value,
+ max_value=RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT.value,
+ required=False,
+ help_text=(
+ "Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected."
+ ),
+ )
+
+
class DashboardSubscribeNudgeResponseSerializer(serializers.Serializer):
created = serializers.BooleanField(
help_text="Whether a nudge notification was created. False when one was already sent recently "
@@ -2598,9 +2641,15 @@ class DashboardSubscribeNudgeResponseSerializer(serializers.Serializer):
),
# Dashboards nest insight payloads via `tiles[].insight`, so the deprecated-`dashboards`-field
# opt-in applies here too — on every action whose response uses DashboardSerializer.
- create=extend_schema(parameters=[INCLUDE_DASHBOARDS_PARAMETER]),
+ create=extend_schema(
+ request=DashboardWriteOpenApiSerializer,
+ parameters=[INCLUDE_DASHBOARDS_PARAMETER],
+ ),
retrieve=extend_schema(parameters=[INCLUDE_DASHBOARDS_PARAMETER]),
- update=extend_schema(parameters=[INCLUDE_DASHBOARDS_PARAMETER]),
+ update=extend_schema(
+ request=DashboardWriteOpenApiSerializer,
+ parameters=[INCLUDE_DASHBOARDS_PARAMETER],
+ ),
partial_update=extend_schema(request=PatchedDashboardOpenApiSerializer, parameters=[INCLUDE_DASHBOARDS_PARAMETER]),
)
class DashboardsViewSet(
diff --git a/products/dashboards/backend/api/test/test_dashboard_filters_validation.py b/products/dashboards/backend/api/test/test_dashboard_filters_validation.py
index f653f00d62b8..a47da348fccc 100644
--- a/products/dashboards/backend/api/test/test_dashboard_filters_validation.py
+++ b/products/dashboards/backend/api/test/test_dashboard_filters_validation.py
@@ -4,6 +4,18 @@ from parameterized import parameterized
from rest_framework import serializers
from products.dashboards.backend.api.dashboard import DashboardSerializer
+from products.dashboards.backend.models.dashboard import Dashboard
+
+
+class TestDashboardRestrictionLevelValidation(SimpleTestCase):
+ @parameterized.expand([("create", False), ("update", True)])
+ def test_rejects_legacy_collaborator_level(self, _name: str, partial: bool) -> None:
+ serializer = DashboardSerializer(
+ data={"restriction_level": Dashboard.RestrictionLevel.ONLY_COLLABORATORS_CAN_EDIT}, partial=partial
+ )
+
+ assert not serializer.is_valid()
+ assert "restriction_level" in serializer.errors
class TestDashboardFiltersValidation(SimpleTestCase):
diff --git a/products/dashboards/backend/api/test/test_dashboard_openapi.py b/products/dashboards/backend/api/test/test_dashboard_openapi.py
index fce0d4a17a99..a8628f11d874 100644
--- a/products/dashboards/backend/api/test/test_dashboard_openapi.py
+++ b/products/dashboards/backend/api/test/test_dashboard_openapi.py
@@ -1,9 +1,11 @@
from drf_spectacular.generators import SchemaGenerator
from rest_framework import serializers
+from products.dashboards.backend.api.dashboard import DashboardWriteOpenApiSerializer
from products.dashboards.backend.api.test.dashboard_openapi_test_helpers import (
dashboard_patch_runtime_openapi_field_names,
)
+from products.dashboards.backend.facade.enums import RestrictionLevel
from products.dashboards.backend.widget_specs.openapi import PatchedDashboardOpenApiSerializer
@@ -19,6 +21,13 @@ def _patched_dashboard_openapi_component_properties(schema: dict) -> frozenset[s
class TestDashboardPatchOpenApiContract:
+ def test_write_schemas_exclude_legacy_collaborator_level(self) -> None:
+ supported_level = RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT.value
+ for serializer in (DashboardWriteOpenApiSerializer(), PatchedDashboardOpenApiSerializer()):
+ field = serializer.fields["restriction_level"]
+ assert isinstance(field, serializers.IntegerField)
+ assert field.min_value == field.max_value == supported_level
+
def test_patched_dashboard_openapi_covers_runtime_patch_fields(self) -> None:
runtime_fields = dashboard_patch_runtime_openapi_field_names()
openapi_fields = frozenset(PatchedDashboardOpenApiSerializer().fields.keys())
diff --git a/products/dashboards/backend/widget_specs/openapi.py b/products/dashboards/backend/widget_specs/openapi.py
index 61e26c88dee5..3163170aa639 100644
--- a/products/dashboards/backend/widget_specs/openapi.py
+++ b/products/dashboards/backend/widget_specs/openapi.py
@@ -396,10 +396,13 @@ class PatchedDashboardOpenApiSerializer(serializers.Serializer):
help_text="ID of the color theme used for chart visualizations.",
)
tags = serializers.ListField(child=serializers.CharField(), required=False)
- restriction_level = serializers.ChoiceField(
- choices=RestrictionLevel.choices,
+ restriction_level = serializers.IntegerField(
+ min_value=RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT.value,
+ max_value=RestrictionLevel.EVERYONE_IN_PROJECT_CAN_EDIT.value,
required=False,
- help_text="Who can edit this dashboard.",
+ help_text=(
+ "Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected."
+ ),
)
quick_filter_ids = serializers.ListField(
child=serializers.CharField(),
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index c34f8f8ea013..16301cb0c25d 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -275,7 +275,7 @@ export interface DashboardBasicApi {
readonly deleted: boolean
readonly creation_mode: DashboardCreationModeEnumApi
tags?: unknown[]
- /** Controls who can edit the dashboard.
+ /** Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
*
* * `21` - Everyone in the project can edit
* * `37` - Only those invited to this dashboard can edit */
@@ -304,24 +304,24 @@ export interface PaginatedDashboardBasicListApi {
results: DashboardBasicApi[]
}
-export type DashboardApiFilters = { [key: string]: unknown }
+export type DashboardWriteOpenApiApiFilters = { [key: string]: unknown }
/**
* @nullable
*/
-export type DashboardApiVariables = { [key: string]: unknown } | null
+export type DashboardWriteOpenApiApiVariables = { [key: string]: unknown } | null
/**
* @nullable
*/
-export type DashboardApiPersistedFilters = { [key: string]: unknown } | null
+export type DashboardWriteOpenApiApiPersistedFilters = { [key: string]: unknown } | null
/**
* @nullable
*/
-export type DashboardApiPersistedVariables = { [key: string]: unknown } | null
+export type DashboardWriteOpenApiApiPersistedVariables = { [key: string]: unknown } | null
-export type DashboardApiTilesItem = { [key: string]: unknown }
+export type DashboardWriteOpenApiApiTilesItem = { [key: string]: unknown }
/**
* * `auto` - auto
@@ -408,6 +408,131 @@ export interface DashboardCustomizationApi {
layout_compaction?: LayoutCompactionEnumApi
}
+/**
+ * Serializer mixin that handles tags for objects.
+ */
+export interface DashboardWriteOpenApiApi {
+ readonly id: number
+ /**
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null
+ description?: string
+ pinned?: boolean
+ readonly created_at: string
+ readonly created_by: UserBasicApi
+ /** @nullable */
+ readonly last_accessed_at: string | null
+ /** @nullable */
+ readonly last_viewed_at: string | null
+ /**
+ * Path of the project-tree folder this dashboard is filed under in the file system, e.g. 'Unfiled/Dashboards'. An empty string means the project root; null means the dashboard has no file system entry. The dashboard's own name is not part of the path.
+ * @nullable
+ */
+ readonly folder: string | null
+ /**
+ * Id of this dashboard's file system entry, or null when it has none. Together with `file_system_path` this is everything a caller needs to move the dashboard between folders, so a list page does not have to look the entry up separately.
+ * @nullable
+ */
+ readonly file_system_id: string | null
+ /**
+ * Full path of this dashboard's file system entry, e.g. 'Unfiled/Dashboards/Revenue'. Unlike `folder` this keeps the dashboard's own name as the last segment, which is what a move needs in order to compute the destination path. Null when it has no entry.
+ * @nullable
+ */
+ readonly file_system_path: string | null
+ readonly is_shared: boolean
+ deleted?: boolean
+ readonly creation_mode: DashboardCreationModeEnumApi
+ readonly filters: DashboardWriteOpenApiApiFilters
+ /** @nullable */
+ readonly variables: DashboardWriteOpenApiApiVariables
+ /**
+ * Colors pinned to specific breakdown values across the dashboard's tiles. A list of entries, not an object keyed by breakdown value. Send an empty list to clear them.
+ * @nullable
+ */
+ breakdown_colors?: BreakdownColorConfigApi[] | null
+ /**
+ * ID of the color theme used for chart visualizations.
+ * @nullable
+ */
+ data_color_theme_id?: number | null
+ tags?: unknown[]
+ /**
+ * Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ * @minimum 21
+ * @maximum 21
+ */
+ restriction_level?: number
+ readonly effective_restriction_level: RestrictionLevelEnumApi
+ readonly effective_privilege_level: PrivilegeLevelEnumApi
+ /**
+ * The effective access level the user has for this object
+ * @nullable
+ */
+ readonly user_access_level: string | null
+ readonly access_control_version: string
+ /** @nullable */
+ last_refresh?: string | null
+ /** @nullable */
+ readonly persisted_filters: DashboardWriteOpenApiApiPersistedFilters
+ /** @nullable */
+ readonly persisted_variables: DashboardWriteOpenApiApiPersistedVariables
+ readonly team_id: number
+ /**
+ * List of quick filter IDs associated with this dashboard
+ * @nullable
+ */
+ quick_filter_ids?: string[] | null
+ /** Dashboard display settings. */
+ readonly customization: DashboardCustomizationApi
+ /** Named tile density preset. Use tight, condensed, standard, relaxed, or wide.
+ *
+ * * `tight` - tight
+ * * `condensed` - condensed
+ * * `standard` - standard
+ * * `relaxed` - relaxed
+ * * `wide` - wide */
+ grid_spacing?: TileSpacingEnumApi
+ /** How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.
+ *
+ * * `vertical` - vertical
+ * * `horizontal` - horizontal
+ * * `stable` - stable */
+ layout_compaction?: LayoutCompactionEnumApi
+ /** @nullable */
+ readonly tiles: readonly DashboardWriteOpenApiApiTilesItem[] | null
+ /** Template key to create the dashboard from a predefined template. */
+ use_template?: string
+ /**
+ * ID of an existing dashboard to duplicate.
+ * @nullable
+ */
+ use_dashboard?: number | null
+ /** When deleting, also delete insights that are only on this dashboard. */
+ delete_insights?: boolean
+ _create_in_folder?: string
+}
+
+export type DashboardApiFilters = { [key: string]: unknown }
+
+/**
+ * @nullable
+ */
+export type DashboardApiVariables = { [key: string]: unknown } | null
+
+/**
+ * @nullable
+ */
+export type DashboardApiPersistedFilters = { [key: string]: unknown } | null
+
+/**
+ * @nullable
+ */
+export type DashboardApiPersistedVariables = { [key: string]: unknown } | null
+
+export type DashboardApiTilesItem = { [key: string]: unknown }
+
/**
* Serializer mixin that handles tags for objects.
*/
@@ -423,7 +548,7 @@ export interface DashboardApi {
readonly created_at: string
readonly created_by: UserBasicApi
/** @nullable */
- last_accessed_at?: string | null
+ readonly last_accessed_at: string | null
/** @nullable */
readonly last_viewed_at: string | null
/**
@@ -458,6 +583,10 @@ export interface DashboardApi {
*/
data_color_theme_id?: number | null
tags?: unknown[]
+ /** Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ *
+ * * `21` - Everyone in the project can edit
+ * * `37` - Only those invited to this dashboard can edit */
restriction_level?: RestrictionLevelEnumApi
readonly effective_restriction_level: RestrictionLevelEnumApi
readonly effective_privilege_level: PrivilegeLevelEnumApi
@@ -1110,11 +1239,12 @@ export interface PatchedPatchedDashboardOpenApiApi {
*/
data_color_theme_id?: number | null
tags?: string[]
- /** Who can edit this dashboard.
- *
- * * `21` - Everyone in the project can edit
- * * `37` - Only those invited to this dashboard can edit */
- restriction_level?: RestrictionLevelEnumApi
+ /**
+ * Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ * @minimum 21
+ * @maximum 21
+ */
+ restriction_level?: number
/**
* List of quick filter IDs associated with this dashboard.
* @nullable
diff --git a/products/dashboards/frontend/generated/api.ts b/products/dashboards/frontend/generated/api.ts
index 228e0445a7ad..2648f8db6e7b 100644
--- a/products/dashboards/frontend/generated/api.ts
+++ b/products/dashboards/frontend/generated/api.ts
@@ -22,6 +22,7 @@ import type {
DashboardTemplateApi,
DashboardTemplatesListParams,
DashboardTileApi,
+ DashboardWriteOpenApiApi,
DashboardsBulkUpdateTagsCreateParams,
DashboardsCopyTileCreateParams,
DashboardsCreateFromTemplateJsonCreateParams,
@@ -272,7 +273,7 @@ export const getDashboardsCreateUrl = (projectId: string, params?: DashboardsCre
export const dashboardsCreate = async (
projectId: string,
- dashboardApi?: NonReadonly<DashboardApi>,
+ dashboardWriteOpenApiApi?: NonReadonly<DashboardWriteOpenApiApi>,
params?: DashboardsCreateParams,
options?: RequestInit
): Promise<DashboardApi> => {
@@ -280,7 +281,7 @@ export const dashboardsCreate = async (
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(dashboardApi),
+ body: JSON.stringify(dashboardWriteOpenApiApi),
})
}
@@ -380,7 +381,7 @@ export const getDashboardsUpdateUrl = (projectId: string, id: number, params?: D
export const dashboardsUpdate = async (
projectId: string,
id: number,
- dashboardApi?: NonReadonly<DashboardApi>,
+ dashboardWriteOpenApiApi?: NonReadonly<DashboardWriteOpenApiApi>,
params?: DashboardsUpdateParams,
options?: RequestInit
): Promise<DashboardApi> => {
@@ -388,7 +389,7 @@ export const dashboardsUpdate = async (
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(dashboardApi),
+ body: JSON.stringify(dashboardWriteOpenApiApi),
})
}
diff --git a/products/dashboards/frontend/generated/api.zod.ts b/products/dashboards/frontend/generated/api.zod.ts
index ac37748197eb..6ac2f8709ba1 100644
--- a/products/dashboards/frontend/generated/api.zod.ts
+++ b/products/dashboards/frontend/generated/api.zod.ts
@@ -132,6 +132,9 @@ export const DashboardTemplatesCopyBetweenProjectsCreateBody = /* @__PURE__ */ z
export const dashboardsCreateBodyNameMax = 400
export const dashboardsCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')
+export const dashboardsCreateBodyRestrictionLevelMin = 21
+export const dashboardsCreateBodyRestrictionLevelMax = 21
+
export const dashboardsCreateBodyDeleteInsightsDefault = false
export const DashboardsCreateBody = /* @__PURE__ */ zod
@@ -139,7 +142,6 @@ export const DashboardsCreateBody = /* @__PURE__ */ zod
name: zod.string().max(dashboardsCreateBodyNameMax).nullish(),
description: zod.string().optional(),
pinned: zod.boolean().optional(),
- last_accessed_at: zod.iso.datetime({ offset: true }).nullish(),
deleted: zod.boolean().optional(),
breakdown_colors: zod
.array(
@@ -184,10 +186,12 @@ export const DashboardsCreateBody = /* @__PURE__ */ zod
data_color_theme_id: zod.number().nullish().describe('ID of the color theme used for chart visualizations.'),
tags: zod.array(zod.unknown()).optional(),
restriction_level: zod
- .union([zod.literal(21), zod.literal(37)])
+ .number()
+ .min(dashboardsCreateBodyRestrictionLevelMin)
+ .max(dashboardsCreateBodyRestrictionLevelMax)
.optional()
.describe(
- '\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.'
),
last_refresh: zod.iso.datetime({ offset: true }).nullish(),
quick_filter_ids: zod
@@ -235,6 +239,9 @@ export const DashboardsCollaboratorsCreateBody = /* @__PURE__ */ zod.object({
export const dashboardsUpdateBodyNameMax = 400
export const dashboardsUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')
+export const dashboardsUpdateBodyRestrictionLevelMin = 21
+export const dashboardsUpdateBodyRestrictionLevelMax = 21
+
export const dashboardsUpdateBodyDeleteInsightsDefault = false
export const DashboardsUpdateBody = /* @__PURE__ */ zod
@@ -242,7 +249,6 @@ export const DashboardsUpdateBody = /* @__PURE__ */ zod
name: zod.string().max(dashboardsUpdateBodyNameMax).nullish(),
description: zod.string().optional(),
pinned: zod.boolean().optional(),
- last_accessed_at: zod.iso.datetime({ offset: true }).nullish(),
deleted: zod.boolean().optional(),
breakdown_colors: zod
.array(
@@ -287,10 +293,12 @@ export const DashboardsUpdateBody = /* @__PURE__ */ zod
data_color_theme_id: zod.number().nullish().describe('ID of the color theme used for chart visualizations.'),
tags: zod.array(zod.unknown()).optional(),
restriction_level: zod
- .union([zod.literal(21), zod.literal(37)])
+ .number()
+ .min(dashboardsUpdateBodyRestrictionLevelMin)
+ .max(dashboardsUpdateBodyRestrictionLevelMax)
.optional()
.describe(
- '\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.'
),
last_refresh: zod.iso.datetime({ offset: true }).nullish(),
quick_filter_ids: zod
@@ -329,6 +337,9 @@ export const DashboardsUpdateBody = /* @__PURE__ */ zod
export const dashboardsPartialUpdateBodyNameMax = 400
export const dashboardsPartialUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')
+export const dashboardsPartialUpdateBodyRestrictionLevelMin = 21
+export const dashboardsPartialUpdateBodyRestrictionLevelMax = 21
+
export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMin = 0
export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMax = 11
@@ -479,13 +490,12 @@ export const DashboardsPartialUpdateBody = /* @__PURE__ */ zod
data_color_theme_id: zod.number().nullish().describe('ID of the color theme used for chart visualizations.'),
tags: zod.array(zod.string()).optional(),
restriction_level: zod
- .union([zod.literal(21), zod.literal(37)])
- .describe(
- '\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
- )
+ .number()
+ .min(dashboardsPartialUpdateBodyRestrictionLevelMin)
+ .max(dashboardsPartialUpdateBodyRestrictionLevelMax)
.optional()
.describe(
- 'Who can edit this dashboard.\n\n\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.'
),
quick_filter_ids: zod
.array(zod.string())
@@ -3720,7 +3730,6 @@ export const DashboardsCreateFromTemplateJsonCreateBody = /* @__PURE__ */ zod
name: zod.string().max(dashboardsCreateFromTemplateJsonCreateBodyNameMax).nullish(),
description: zod.string().optional(),
pinned: zod.boolean().optional(),
- last_accessed_at: zod.iso.datetime({ offset: true }).nullish(),
deleted: zod.boolean().optional(),
breakdown_colors: zod
.array(
@@ -3766,9 +3775,12 @@ export const DashboardsCreateFromTemplateJsonCreateBody = /* @__PURE__ */ zod
tags: zod.array(zod.unknown()).optional(),
restriction_level: zod
.union([zod.literal(21), zod.literal(37)])
- .optional()
.describe(
'\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ )
+ .optional()
+ .describe(
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.\n\n\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
),
last_refresh: zod.iso.datetime({ offset: true }).nullish(),
quick_filter_ids: zod
@@ -3821,7 +3833,6 @@ export const DashboardsCreateUnlistedDashboardCreateBody = /* @__PURE__ */ zod
name: zod.string().max(dashboardsCreateUnlistedDashboardCreateBodyNameMax).nullish(),
description: zod.string().optional(),
pinned: zod.boolean().optional(),
- last_accessed_at: zod.iso.datetime({ offset: true }).nullish(),
deleted: zod.boolean().optional(),
breakdown_colors: zod
.array(
@@ -3867,9 +3878,12 @@ export const DashboardsCreateUnlistedDashboardCreateBody = /* @__PURE__ */ zod
tags: zod.array(zod.unknown()).optional(),
restriction_level: zod
.union([zod.literal(21), zod.literal(37)])
- .optional()
.describe(
'\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ )
+ .optional()
+ .describe(
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.\n\n\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
),
last_refresh: zod.iso.datetime({ offset: true }).nullish(),
quick_filter_ids: zod
diff --git a/products/dashboards/mcp/tools.yaml b/products/dashboards/mcp/tools.yaml
index a2c77d0462f4..c35f8f6f8d29 100644
--- a/products/dashboards/mcp/tools.yaml
+++ b/products/dashboards/mcp/tools.yaml
@@ -57,6 +57,10 @@ tools:
- persisted_filters
- persisted_variables
- _create_in_folder
+ param_overrides:
+ restriction_level:
+ description: >
+ Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.
response:
exclude:
- effective_restriction_level
@@ -458,20 +462,21 @@ tools:
title: Update dashboard
description: >
Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned
- status, tags, filters, and restriction level. After you create or add insight tiles, call dashboard-get to
- get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h
- per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is
- 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole
- number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show
- hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to
- change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile
- you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order
- and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile
- sizes. The same `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from
- dashboard-get plus the fields to change (`config`, `name`, `description`). That is the same PATCH path the
- UI uses, but prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget
- tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to
- save context — use dashboard-insights-run to fetch the actual data for each insight.
+ status, tags, filters, and restriction level 21. Legacy value 37 is deprecated and rejected by the API.
+ After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each
+ tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type,
+ including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and
+ height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's
+ minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's
+ whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and
+ overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set
+ `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use
+ dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. The same
+ `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from dashboard-get plus
+ the fields to change (`config`, `name`, `description`). That is the same PATCH path the UI uses, but prefer
+ dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget tiles to this
+ dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context
+ — use dashboard-insights-run to fetch the actual data for each insight.
exclude_params:
- creation_mode
- effective_restriction_level
@@ -487,6 +492,9 @@ tools:
param_overrides:
id:
cast: string-int
+ restriction_level:
+ description: >
+ Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.
response:
exclude:
- effective_restriction_level
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 9bc9a06e01ce..3092e5823d0c 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -3503,7 +3503,7 @@
}
},
"dashboard-update": {
- "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, filters, and restriction level. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. The same `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from dashboard-get plus the fields to change (`config`, `name`, `description`). That is the same PATCH path the UI uses, but prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
+ "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, filters, and restriction level 21. Legacy value 37 is deprecated and rejected by the API. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. The same `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from dashboard-get plus the fields to change (`config`, `name`, `description`). That is the same PATCH path the UI uses, but prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Update dashboard",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index de087915b433..203fd3b0efc9 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -3518,7 +3518,7 @@
}
},
"dashboard-update": {
- "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, filters, and restriction level. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. The same `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from dashboard-get plus the fields to change (`config`, `name`, `description`). That is the same PATCH path the UI uses, but prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
+ "description": "Resize, reposition, or update dashboard tiles. It can also update the dashboard name, description, pinned status, tags, filters, and restriction level 21. Legacy value 37 is deprecated and rejected by the API. After you create or add insight tiles, call dashboard-get to get their tile IDs, then pass `tiles` with each tile's `id` and a `layouts` object holding x, y, w, and h per breakpoint. This works for every tile type, including insight tiles. The desktop grid (`layouts.sm`) is 12 columns wide. Set each tile's width and height for its content and importance. Width can be any whole number from 1 to 12, subject to the tile's minimum size. Mixed rows such as 8-wide and 4-wide tiles can show hierarchy. A write replaces the tile's whole layout, so send a complete box, not just the value you want to change. Boxes are stored as sent and overlaps are not resolved, so plan the whole grid and send every tile you move in one request. Only set `layouts.sm`: the dashboard derives the mobile layout from the sm order and heights. Use dashboard-reorder-tiles only to repack the whole dashboard with preserved or uniform tile sizes. The same `tiles` array also updates a widget tile's own settings: add a nested `widget.id` from dashboard-get plus the fields to change (`config`, `name`, `description`). That is the same PATCH path the UI uses, but prefer dashboard-widgets-batch-update, which takes just a tile_id per widget. To add new widget tiles to this dashboard, use dashboard-widgets-batch-add instead. The returned tiles omit insight results to save context — use dashboard-insights-run to fetch the actual data for each insight.",
"category": "Dashboards",
"feature": "dashboards",
"summary": "Update dashboard",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4fd664e44c0b..4f161dc39657 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -26813,7 +26813,7 @@ export namespace Schemas {
readonly created_at: string;
readonly created_by: UserBasic;
/** @nullable */
- last_accessed_at?: string | null;
+ readonly last_accessed_at: string | null;
/** @nullable */
readonly last_viewed_at: string | null;
/**
@@ -26848,6 +26848,10 @@ export namespace Schemas {
*/
data_color_theme_id?: number | null;
tags?: unknown[];
+ /** Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ *
+ * * `21` - Everyone in the project can edit
+ * * `37` - Only those invited to this dashboard can edit */
restriction_level?: RestrictionLevelEnum;
readonly effective_restriction_level: RestrictionLevelEnum;
readonly effective_privilege_level: PrivilegeLevelEnum;
@@ -26938,7 +26942,7 @@ export namespace Schemas {
readonly deleted: boolean;
readonly creation_mode: DashboardCreationModeEnum;
tags?: unknown[];
- /** Controls who can edit the dashboard.
+ /** Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
*
* * `21` - Everyone in the project can edit
* * `37` - Only those invited to this dashboard can edit */
@@ -27198,6 +27202,131 @@ export namespace Schemas {
error: string | null;
}
+ export type DashboardWriteOpenApiFilters = { [key: string]: unknown };
+
+ /**
+ * @nullable
+ */
+ export type DashboardWriteOpenApiVariables = { [key: string]: unknown } | null;
+
+ /**
+ * @nullable
+ */
+ export type DashboardWriteOpenApiPersistedFilters = { [key: string]: unknown } | null;
+
+ /**
+ * @nullable
+ */
+ export type DashboardWriteOpenApiPersistedVariables = { [key: string]: unknown } | null;
+
+ export type DashboardWriteOpenApiTilesItem = { [key: string]: unknown };
+
+ /**
+ * Serializer mixin that handles tags for objects.
+ */
+ export interface DashboardWriteOpenApi {
+ readonly id: number;
+ /**
+ * @maxLength 400
+ * @nullable
+ */
+ name?: string | null;
+ description?: string;
+ pinned?: boolean;
+ readonly created_at: string;
+ readonly created_by: UserBasic;
+ /** @nullable */
+ readonly last_accessed_at: string | null;
+ /** @nullable */
+ readonly last_viewed_at: string | null;
+ /**
+ * Path of the project-tree folder this dashboard is filed under in the file system, e.g. 'Unfiled/Dashboards'. An empty string means the project root; null means the dashboard has no file system entry. The dashboard's own name is not part of the path.
+ * @nullable
+ */
+ readonly folder: string | null;
+ /**
+ * Id of this dashboard's file system entry, or null when it has none. Together with `file_system_path` this is everything a caller needs to move the dashboard between folders, so a list page does not have to look the entry up separately.
+ * @nullable
+ */
+ readonly file_system_id: string | null;
+ /**
+ * Full path of this dashboard's file system entry, e.g. 'Unfiled/Dashboards/Revenue'. Unlike `folder` this keeps the dashboard's own name as the last segment, which is what a move needs in order to compute the destination path. Null when it has no entry.
+ * @nullable
+ */
+ readonly file_system_path: string | null;
+ readonly is_shared: boolean;
+ deleted?: boolean;
+ readonly creation_mode: DashboardCreationModeEnum;
+ readonly filters: DashboardWriteOpenApiFilters;
+ /** @nullable */
+ readonly variables: DashboardWriteOpenApiVariables;
+ /**
+ * Colors pinned to specific breakdown values across the dashboard's tiles. A list of entries, not an object keyed by breakdown value. Send an empty list to clear them.
+ * @nullable
+ */
+ breakdown_colors?: BreakdownColorConfig[] | null;
+ /**
+ * ID of the color theme used for chart visualizations.
+ * @nullable
+ */
+ data_color_theme_id?: number | null;
+ tags?: unknown[];
+ /**
+ * Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ * @minimum 21
+ * @maximum 21
+ */
+ restriction_level?: number;
+ readonly effective_restriction_level: RestrictionLevelEnum;
+ readonly effective_privilege_level: PrivilegeLevelEnum;
+ /**
+ * The effective access level the user has for this object
+ * @nullable
+ */
+ readonly user_access_level: string | null;
+ readonly access_control_version: string;
+ /** @nullable */
+ last_refresh?: string | null;
+ /** @nullable */
+ readonly persisted_filters: DashboardWriteOpenApiPersistedFilters;
+ /** @nullable */
+ readonly persisted_variables: DashboardWriteOpenApiPersistedVariables;
+ readonly team_id: number;
+ /**
+ * List of quick filter IDs associated with this dashboard
+ * @nullable
+ */
+ quick_filter_ids?: string[] | null;
+ /** Dashboard display settings. */
+ readonly customization: DashboardCustomization;
+ /** Named tile density preset. Use tight, condensed, standard, relaxed, or wide.
+ *
+ * * `tight` - tight
+ * * `condensed` - condensed
+ * * `standard` - standard
+ * * `relaxed` - relaxed
+ * * `wide` - wide */
+ grid_spacing?: TileSpacingEnum;
+ /** How tiles rearrange after a move or resize. vertical stacks tiles upward, horizontal stacks tiles to the left, and stable preserves positions while moving colliding tiles.
+ *
+ * * `vertical` - vertical
+ * * `horizontal` - horizontal
+ * * `stable` - stable */
+ layout_compaction?: LayoutCompactionEnum;
+ /** @nullable */
+ readonly tiles: readonly DashboardWriteOpenApiTilesItem[] | null;
+ /** Template key to create the dashboard from a predefined template. */
+ use_template?: string;
+ /**
+ * ID of an existing dashboard to duplicate.
+ * @nullable
+ */
+ use_dashboard?: number | null;
+ /** When deleting, also delete insights that are only on this dashboard. */
+ delete_insights?: boolean;
+ _create_in_folder?: string;
+ }
+
export interface DataCatalogCertification {
readonly id: string;
/**
@@ -79507,11 +79636,12 @@ export namespace Schemas {
*/
data_color_theme_id?: number | null;
tags?: string[];
- /** Who can edit this dashboard.
- *
- * * `21` - Everyone in the project can edit
- * * `37` - Only those invited to this dashboard can edit */
- restriction_level?: RestrictionLevelEnum;
+ /**
+ * Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.
+ * @minimum 21
+ * @maximum 21
+ */
+ restriction_level?: number;
/**
* List of quick filter IDs associated with this dashboard.
* @nullable
diff --git a/services/mcp/src/generated/dashboards/api.ts b/services/mcp/src/generated/dashboards/api.ts
index 311d67a7685a..c8a4de7ae7df 100644
--- a/services/mcp/src/generated/dashboards/api.ts
+++ b/services/mcp/src/generated/dashboards/api.ts
@@ -109,6 +109,9 @@ export const DashboardsCreateQueryParams = () => zod.object({
export const dashboardsCreateBodyNameMax = 400
export const dashboardsCreateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')
+export const dashboardsCreateBodyRestrictionLevelMin = 21
+export const dashboardsCreateBodyRestrictionLevelMax = 21
+
export const dashboardsCreateBodyDeleteInsightsDefault = false
export const DashboardsCreateBody = () => zod
@@ -159,10 +162,12 @@ export const DashboardsCreateBody = () => zod
data_color_theme_id: zod.number().nullish().describe('ID of the color theme used for chart visualizations.'),
tags: zod.array(zod.unknown()).optional(),
restriction_level: zod
- .union([zod.literal(21), zod.literal(37)])
+ .number()
+ .min(dashboardsCreateBodyRestrictionLevelMin)
+ .max(dashboardsCreateBodyRestrictionLevelMax)
.optional()
.describe(
- '\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.'
),
quick_filter_ids: zod
.array(zod.string())
@@ -249,6 +254,9 @@ export const DashboardsPartialUpdateQueryParams = () => zod.object({
export const dashboardsPartialUpdateBodyNameMax = 400
export const dashboardsPartialUpdateBodyBreakdownColorsItemColorTokenRegExp = new RegExp('^preset-[1-9][0-9]\*$')
+export const dashboardsPartialUpdateBodyRestrictionLevelMin = 21
+export const dashboardsPartialUpdateBodyRestrictionLevelMax = 21
+
export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMin = 0
export const dashboardsPartialUpdateBodyTilesItemLayoutsOneSmOneXMax = 11
@@ -397,13 +405,12 @@ export const DashboardsPartialUpdateBody = () => zod
data_color_theme_id: zod.number().nullish().describe('ID of the color theme used for chart visualizations.'),
tags: zod.array(zod.string()).optional(),
restriction_level: zod
- .union([zod.literal(21), zod.literal(37)])
- .describe(
- '\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
- )
+ .number()
+ .min(dashboardsPartialUpdateBodyRestrictionLevelMin)
+ .max(dashboardsPartialUpdateBodyRestrictionLevelMax)
.optional()
.describe(
- 'Who can edit this dashboard.\n\n\* `21` - Everyone in the project can edit\n\* `37` - Only those invited to this dashboard can edit'
+ 'Only restriction level 21 is accepted on create and update. Legacy value 37 is deprecated and rejected.'
),
quick_filter_ids: zod
.array(zod.string())
diff --git a/services/mcp/src/tools/generated/dashboards.ts b/services/mcp/src/tools/generated/dashboards.ts
index d3d1df48d78a..71eecb059946 100644
--- a/services/mcp/src/tools/generated/dashboards.ts
+++ b/services/mcp/src/tools/generated/dashboards.ts
@@ -20,7 +20,13 @@ import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
const DashboardCreateSchema = () => {
const DashboardsCreateBody = orvalSchemas.DashboardsCreateBody()
const DashboardsCreateQueryParams = orvalSchemas.DashboardsCreateQueryParams()
- return DashboardsCreateQueryParams.omit({ format: true }).extend(DashboardsCreateBody.shape)
+ return DashboardsCreateQueryParams.omit({ format: true })
+ .extend(DashboardsCreateBody.shape)
+ .extend({
+ restriction_level: DashboardsCreateBody.shape['restriction_level'].describe(
+ 'Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.'
+ ),
+ })
}
const dashboardCreate = (): ToolBase<
@@ -565,7 +571,12 @@ const DashboardUpdateSchema = () => {
return DashboardsPartialUpdateParams.omit({ project_id: true })
.extend(DashboardsPartialUpdateQueryParams.omit({ format: true }).shape)
.extend(DashboardsPartialUpdateBody.shape)
- .extend({ id: z.preprocess(castStringToInt, DashboardsPartialUpdateParams.shape['id']) })
+ .extend({
+ id: z.preprocess(castStringToInt, DashboardsPartialUpdateParams.shape['id']),
+ restriction_level: DashboardsPartialUpdateBody.shape['restriction_level'].describe(
+ 'Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.'
+ ),
+ })
}
const dashboardUpdate = (): ToolBase<
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json
index d8590ca3667a..5ed33321da53 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-create.json
@@ -131,17 +131,10 @@
"description": "List of quick filter IDs associated with this dashboard"
},
"restriction_level": {
- "anyOf": [
- {
- "const": 21,
- "type": "number"
- },
- {
- "const": 37,
- "type": "number"
- }
- ],
- "description": "* `21` - Everyone in the project can edit\n* `37` - Only those invited to this dashboard can edit"
+ "description": "Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.",
+ "maximum": 21,
+ "minimum": 21,
+ "type": "number"
},
"tags": {
"items": {},
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
index 5b49fc15d307..f3eca7f9740e 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/dashboard-update.json
@@ -165,17 +165,10 @@
"description": "List of quick filter IDs associated with this dashboard."
},
"restriction_level": {
- "anyOf": [
- {
- "const": 21,
- "type": "number"
- },
- {
- "const": 37,
- "type": "number"
- }
- ],
- "description": "Who can edit this dashboard.\n\n* `21` - Everyone in the project can edit\n* `37` - Only those invited to this dashboard can edit"
+ "description": "Set to 21 for everyone in the project to edit. Legacy value 37 is deprecated and rejected by the API.",
+ "maximum": 21,
+ "minimum": 21,
+ "type": "number"
},
"tags": {
"items": {