Skip to content

Commit dd10661

Browse files
fix(dashboards): Add context logging for widget mismatch errors
Capture org slug, dashboard ID, widget ID, and existing vs requested widget IDs when a widget update targets a widget not belonging to the dashboard. This helps debug the root cause of these validation errors in production. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 42d5f41 commit dd10661

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/sentry/api/serializers/rest_framework/dashboard.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,19 @@ def update_widgets(self, instance, widget_data):
862862
# Create a new widget.
863863
self.create_widget(instance, data)
864864
else:
865+
sentry_sdk.set_context(
866+
"dashboard_widget_mismatch",
867+
{
868+
"org_slug": instance.organization.slug,
869+
"dashboard_id": instance.id,
870+
"widget_id": widget_id,
871+
"existing_widget_ids": list(existing_map.keys()),
872+
"requested_widget_ids": widget_ids,
873+
},
874+
)
875+
sentry_sdk.capture_message(
876+
"Attempted to update widget not belonging to dashboard."
877+
)
865878
raise serializers.ValidationError(
866879
"You cannot update widgets that are not part of this dashboard."
867880
)

0 commit comments

Comments
 (0)