Commit 45b07af
fix(dashboards): Add backend validation for widget layout dimensions (#109826)
Replace the custom `LayoutField` with a `LayoutSerializer` using DRF's
built-in `IntegerField` validators to reject invalid widget dimensions
at the API level.
Widgets created via external tools (e.g. LLMs) can have invalid
dimensions like `w: 12` where the grid maximum is `6`. This change
prevents such layouts from being persisted. The `LayoutSerializer` also
lets drf-spectacular auto-generate accurate OpenAPI documentation with
field types and constraints, removing the need for manual
`@extend_schema_field` annotations.
Frontend clamping counterpart:
#109825
Refs DAIN-1266
Co-authored-by: Claude <noreply@anthropic.com>1 parent f55826d commit 45b07af
File tree
2 files changed
+117
-30
lines changed- src/sentry/api/serializers/rest_framework
- tests/sentry/dashboards/endpoints
2 files changed
+117
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 106 | + | |
116 | 107 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | 108 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 109 | + | |
| 110 | + | |
125 | 111 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
131 | 115 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
135 | 125 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
139 | 130 | | |
140 | 131 | | |
141 | 132 | | |
| |||
316 | 307 | | |
317 | 308 | | |
318 | 309 | | |
319 | | - | |
| 310 | + | |
320 | 311 | | |
321 | 312 | | |
322 | 313 | | |
| |||
Lines changed: 96 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1145 | 1145 | | |
1146 | 1146 | | |
1147 | 1147 | | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1148 | 1244 | | |
1149 | 1245 | | |
1150 | 1246 | | |
| |||
0 commit comments