This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Fix bug where pull request cannot be viewed if pullRequest.headRepository is null. #1828
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
If
pullRequest.headRepositoryis null, (which might be the case if, for example, a user deletes the repository), currently we throw an error and the pull request cannot be viewed.This pull request adds a check for this condition, so we can avoid the code that's checking for a non existent property.
Alternate Designs
This approach allows a user to view a pull request where a head repository is null, but they cannot check it out. While it would be possible to fall back to refs/pull/${PR}/head to check out the pull request from dotcom, it seems not worth the added complexity. My assumption is, it's relatively rare for a user to open a cross repository pull request and then delete their fork.
If I'm wrong, and it's more common than I think, I'd be open to revisiting this decision and supporting checkout in this edge case.
Benefits
Users can view pull requests again.
Possible Drawbacks
I can't think of anything, other than writing code always introduces the possibility of more bugs.
Applicable Issues
#1776
Metrics
n/a
Tests
pullRequest.headRepositoryis null.Documentation
N/A
Release Notes
It's not a notable change, dawg. Nothing to see here.