Skip to content

Commit 6e1004f

Browse files
fix(dashboards): Add context logging for widget mismatch errors (#112608)
Capture event when encountering `You cannot update widgets that are not part of this dashboard` on saving dashboards. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c107292 commit 6e1004f

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",
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)