Skip to content

Commit 5c3a9c1

Browse files
skaastenclaude
andcommitted
fix(dashboards): Don't block dashboard save when snapshot serialization fails
If serialize() raises (e.g. user_service RPC failure), the exception was propagating before the transaction block and causing the entire PUT to fail. The revision snapshot is secondary to the save; catch and log the exception so the dashboard update always proceeds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0bd2355 commit 5c3a9c1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/sentry/dashboards/endpoints/organization_dashboard_details.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import annotations
2+
3+
import logging
14
from typing import Any
25

36
import sentry_sdk
@@ -40,6 +43,8 @@
4043
READ_FEATURE = "organizations:dashboards-basic"
4144
REVISIONS_FEATURE = "organizations:dashboards-revisions"
4245

46+
logger = logging.getLogger(__name__)
47+
4348

4449
def _take_dashboard_snapshot(
4550
organization: Organization,
@@ -48,7 +53,8 @@ def _take_dashboard_snapshot(
4853
) -> dict[str, Any] | None:
4954
"""
5055
Serialize the current dashboard state as a snapshot, or return None if the
51-
revisions feature is disabled or the dashboard has no DB record to snapshot.
56+
revisions feature is disabled, the dashboard has no DB record to snapshot,
57+
or serialization fails.
5258
5359
Must be called outside any transaction.atomic block because the serializer
5460
makes hybrid-cloud RPC calls (user_service.serialize_many) that cannot run
@@ -58,7 +64,15 @@ def _take_dashboard_snapshot(
5864
return None
5965
if not features.has(REVISIONS_FEATURE, organization, actor=user):
6066
return None
61-
return serialize(dashboard, user)
67+
try:
68+
return serialize(dashboard, user)
69+
except Exception:
70+
# Snapshot failures must not block the dashboard save. Log and skip.
71+
logger.exception(
72+
"Failed to serialize dashboard snapshot; proceeding without creating revision",
73+
extra={"dashboard_id": dashboard.id},
74+
)
75+
return None
6276

6377

6478
class OrganizationDashboardBase(OrganizationEndpoint):

0 commit comments

Comments
 (0)