[PR #13820] fix: guard null headRepository for deleted fork PRs (#13812) #14823

Open
opened 2026-02-16 18:19:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13820

State: open
Merged: No


Problem

When a PR comes from a fork that has been deleted, the GitHub GraphQL API returns headRepository: null. This causes a crash when accessing prData.headRepository.nameWithOwner in the GitHub Actions workflow handler.

Fix

  1. Type definition: Updated GitHubPullRequest.headRepository to allow null ({ nameWithOwner: string } | null).
  2. Null-safe comparison (line 565): Changed to optional chaining prData.headRepository?.nameWithOwner so deleted-fork PRs fall through to the fork branch path instead of crashing.
  3. Null guard in checkoutForkBranch (line 1040): Added an early check that throws a clear error message when the source repository has been deleted or is inaccessible.

Closes #13812

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13820 **State:** open **Merged:** No --- ## Problem When a PR comes from a fork that has been deleted, the GitHub GraphQL API returns `headRepository: null`. This causes a crash when accessing `prData.headRepository.nameWithOwner` in the GitHub Actions workflow handler. ## Fix 1. **Type definition**: Updated `GitHubPullRequest.headRepository` to allow `null` (`{ nameWithOwner: string } | null`). 2. **Null-safe comparison** (line 565): Changed to optional chaining `prData.headRepository?.nameWithOwner` so deleted-fork PRs fall through to the fork branch path instead of crashing. 3. **Null guard in `checkoutForkBranch`** (line 1040): Added an early check that throws a clear error message when the source repository has been deleted or is inaccessible. Closes #13812
yindo added the pull-request label 2026-02-16 18:19:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14823