Files
magnus919_agent-skills/opensource-contributions/references/cross-fork-pr-workaround.md
T
Magnus Hedemark c5c4d2434a feat: add opensource-contributions skill
Comprehensive open source contribution guidance with progressive disclosure.
Restructured from a single ~23K-token monolithic SKILL.md into a concise
~1.2K-token orchestrator with 10 focused reference files.

Changes:
- SKILL.md: 1,720 lines → 100 lines (AgentSkills.io compliant frontmatter)
- 10 new reference files covering phases 0a-4, pitfalls, default posture
- Portable PR template compliance checker script (stdlib-only)
- All personal context scrubbed for public export
- AGENTS.md + README.md updated with trigger table entry

Signed-off-by: Magnus Hedemark <magnus919@pm.me>
2026-05-28 21:43:30 -04:00

2.5 KiB

Cross-Fork PR Workaround — Session Detail

Background

On 2026-05-11, contributing to NousResearch/hermes-agent from fork magnus919/hermes-agent-1 (note: fork name differs from upstream). gh pr create repeatedly failed with an opaque GraphQL error despite correct parameters.

Error

pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, 
Head user can't be blank, Head repository can't be blank, No commits between 
NousResearch:main and , Head ref must be a branch, not all refs are readable

Attempted Fixes That Did NOT Work

  1. Correcting --head format from user/repo:branch to user:branch

    • --head magnus919/hermes-agent-1:fix/foo--head magnus919:fix/foo
    • Result: same error
  2. Syncing fork's main with upstream

    git fetch upstream main
    git push origin upstream/main:main
    
    • Result: origin/main now matched upstream, but gh pr create still failed
  3. Using gh pr create from within the fork checkout

    • Without --repo flag (let gh infer from cwd)
    • With --repo NousResearch/hermes-agent (explicit)
    • Result: same error both ways

Fix That Worked

Use the GitHub REST API directly, bypassing gh's fork-resolution heuristics entirely:

gh api repos/NousResearch/hermes-agent/pulls \
  -f title='fix(agent): description' \
  -f head='magnus919:fix/tool-call-regex-nested-json' \
  -f base='main' \
  -f body='## Summary\n\nPR body here'

Key points:

  • -f head='username:branch' — username only, not the repo name
  • No -f head='username/repo:branch' — that causes 422 "head is invalid"
  • The API always returns 201 Created for valid cross-fork PRs
  • Response includes full PR object with html_url, number, etc.

Root Cause Hypothesis

gh pr create uses a GraphQL mutation that resolves the head ref through the fork's repository connection. When the fork name differs from the upstream (e.g. hermes-agent-1 vs hermes-agent), gh's fork-resolution heuristics fail silently. The REST API endpoint (POST /repos/:owner/:repo/pulls) accepts a simpler head string that doesn't require the same repo-name resolution.

Update: This Is Not the Only Failure Mode

On 2026-05-18, contributing to shlinkio/shlink, the REST API also failed with 404 despite the compare endpoint confirming status: ahead — see cross-fork-org-restriction.md for this separate failure mode caused by org-level access restrictions. In that case, the GitHub compare URL is the only reliable fallback.