Allow ReviewRequestPageData to process draft diff comments.
Review Request #14561 — Created Aug. 11, 2025 and updated
We recently re-worked our
ReviewRequestPageData
to reduce the amount of
queries we were doing. In that change, we added some processing for diff
comments where we attach pre-loaded diffsets back to the comments.
However, we weren't pre-loading the draft diffset of the review request,
and didn't consider the draft diffset when processing the comments.So if a user was viewing a draft review request and they added a draft
diff comment, this would cause the comment processing to crash on the next
page load. This change includes the draft diffset in our list of loaded
diffsets on theReviewRequestPageData
if the draft is accessible by the
requesting user, allowing the draft diffset to be attached to comments
during processing.
- Ran unit tests.
- Viewed a draft review request that had a draft diffset on it. Created
a diff comment and hard reloaded the page. Made sure the page didn't
crash, whereas previously it would crash with a key error in
diffsets_by_id
. - Viewed a review request that has a draft as an anonymous user. Made
sure that I couldn't see the draft, and couldn't see any draft diff
comments. - Created a draft review request that had a draft diffset and draft
comment on it. Viewed the draft review requets as a superuser/admin
that does not own the draft comment/review, made sure that the admin
could not see the draft diff comment or review.
Summary | ID |
---|---|
228fccade1b4b7f5224fbe73718f7f058b936d04 |
Description | From | Last Updated |
---|---|---|
I think we should still keep this as a single assignment for the initialization. There's no good reason to create … |
|
|
One last thing. Since this is happing at runtime and 7.1.x still supports python 3.8, we need to use cast(List[...], … |
|
|
I saw the discussion, but looking into this, I think we should copy the list instead of casting. The reason … |
|

- Commits:
-
Summary ID 850de5d663600e6748f1ea0e8bcb5ee20aeb660d 7e227c95f42dd988465a0bc648e26292fd51fa53
Checks run (2 succeeded)

- Commits:
-
Summary ID 7e227c95f42dd988465a0bc648e26292fd51fa53 1b4e0a2dad992e78863cb82fe875819f7c22447d