Commit 30f16e7
fix(snapshots): Fix staff auth blocking initial size comparison selection (#112739)
## Summary
The size comparison POST endpoint was applying staff re-auth checks
whenever existing comparisons were found, regardless of context. This
caused staff users to hit a `403 StaffRequired` error on the build
selection page when selecting a pair that already had comparison
results.
**Fix:** Use a `?rerun=true` query parameter to distinguish the "Rerun
Comparison" admin flow from normal comparison triggers.
### Logic paths
| Scenario | `?rerun` | Existing state | Behavior |
|---|---|---|---|
| Build selection page | no | no comparison exists | Creates new
comparison |
| Build selection page | no | SUCCESS/PENDING exists | Returns `status:
"exists"`, navigates to results |
| Build selection page | no | all FAILED | Deletes failed, re-creates
(retry without staff gate) |
| Retry button (failed comparison) | no | all FAILED | Deletes failed,
re-creates (retry without staff gate) |
| "Rerun Comparison" admin button | yes | active superuser/staff |
Deletes and re-runs |
| "Rerun Comparison" admin button | yes | `is_staff` but not re-authed |
`StaffRequired` (triggers re-auth modal) |
| "Rerun Comparison" admin button | yes | non-staff | 403 |
### Files changed
- **Backend**: `project_preprod_size_analysis_compare.py` — branching
logic based on `?rerun` query param
- **Frontend**: `buildComparison.tsx` — rerun mutation now sends
`?rerun=true`
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 65b8f0b commit 30f16e7
File tree
3 files changed
+105
-13
lines changed- src/sentry/preprod/api/endpoints/size_analysis
- static/app/views/preprod/buildComparison
- tests/sentry/preprod/api/endpoints/size_analysis
3 files changed
+105
-13
lines changedLines changed: 28 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
346 | 348 | | |
347 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
348 | 374 | | |
349 | 375 | | |
350 | 376 | | |
351 | 377 | | |
352 | | - | |
| 378 | + | |
353 | 379 | | |
354 | 380 | | |
355 | 381 | | |
| |||
358 | 384 | | |
359 | 385 | | |
360 | 386 | | |
361 | | - | |
362 | | - | |
363 | 387 | | |
364 | 388 | | |
365 | 389 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
Lines changed: 76 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
607 | 609 | | |
608 | 610 | | |
609 | 611 | | |
| |||
616 | 618 | | |
617 | 619 | | |
618 | 620 | | |
619 | | - | |
| 621 | + | |
620 | 622 | | |
621 | 623 | | |
622 | | - | |
623 | | - | |
624 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
625 | 628 | | |
626 | 629 | | |
627 | 630 | | |
| |||
804 | 807 | | |
805 | 808 | | |
806 | 809 | | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
0 commit comments