GPT-5 finding
PR update logic treats 'null' as a valid PR number, causing gh pr edit to fail and skipping PR creation
highbughigh
- .github/workflows/sync-upstream.yml:85
- .github/workflows/sync-upstream.yml:86-87
When no PR exists for the branch, `gh pr list --json number --jq '.[0].number'` evaluates to null and prints the string "null" with a zero exit code. Because the command does not fail, the `|| echo ""` fallback is not triggered. The non-empty string "null" causes the script to take the edit path and run `gh pr edit "null"`, which fails and prevents creating a new PR.
Recommendation
Treat a null result as empty. For example: use `--jq '.[0].number // empty'` so the output is blank when no PR exists, or use `gh pr view --head "$BRANCH"` and branch on its exit code. Example fix: EXISTING=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number // empty') if [ -n "$EXISTING" ]; then gh pr edit "$EXISTING" ... else gh pr create ... fi