Repository navigation
fix(bin): support configured GitHub Enterprise PR hosts - #7489
Conversation
fm_pr_url_parse accepted a GitHub pull request URL only on github.com and hard-set the recorded host, so a task PR on GitHub Enterprise (Cloud *.ghe.com or Enterprise Server) could not be registered, watched for merge, merged, or read back after a merge. A GitHub URL now carries its host like the GitLab, Gerrit, and Forgejo identities already do, with GitHub's owner and repository rules unchanged. github.com needs no configuration and behaves exactly as before. Any other host is accepted only when this home names it in config/github-hosts, because a URL shape cannot tell a real GitHub host from a look-alike such as github.com.evil; only an exact line match authorizes, so comments and malformed lines allow nothing. The parsed host is then carried to every forge call on those paths as GH_HOST, which gh and gh-axi both honor: registration, the static merge poll, the merge command and its pre-merge reads, the merge-outcome read, the teardown read, and the crew-state PR state read. github.com exports nothing and keeps its ambient behavior. Backlog PR links still need the companion tasks-axi change, because that package validates the URL itself.
|
Speaking as Kun's firstmate (OSS triage): thank you @tin-hong, this is careful work, and the read-only live run against a real Enterprise PR is exactly the kind of evidence that helps. Checked head Contract-class (my own read): opt-in. With no VISION.md: One captain aligns (no captain-facing surface). Authority aligns (the captain names the host; look-alikes refused). Scripts/agents aligns (pure script mechanics). Restart aligns (host is part of the durable PR identity). Delegation aligns (merge preflight and refusals unchanged, now on the right host). Vendor aligns (uses gh's own Two notes, neither blocking: the backlog-close link for an Enterprise URL still waits on kunchenguid/tasks-axi#77 (documented in the body), and the changed static poll template means polls armed before an update get rejected, which you documented as the same thing every earlier template change did. Also heads-up that #6910 edits the same GitHub URL regex, so whichever lands second may need a small rebase. I approved the first-time fork workflow runs on this head. Waiting on CI (including the no-mistakes check), so nothing is needed from you right now. |
… ShellCheck comment lines in tests/fm-pr-check-security.test.sh. Canonical lint, the complete behavioral suite, and git diff --check pass. Full CI partition rerun remains with the outer executor
|
Speaking as Kun's firstmate: thanks @tin-hong. The new head I approved this head's fork runs: CI Contract-class: opt-in (unchanged). Without Status: waiting on CI. You don't need to do anything unless it comes back red. If it's green, including no-mistakes, and the PR is still mergeable, this takes the auto-merge path. |
|
Speaking as Kun's firstmate: this is merged. Thank you @tin-hong — really appreciate you taking the time on this. Context: head |
Intent
Fix GitHub issue #5936 (GitHub Enterprise PR URLs such as https://leadsonline.ghe.com///pull/ are rejected, so a task PR on a GitHub Enterprise host cannot be registered, monitored for merge, merged through the merge script, or linked when its backlog item closes) and open the upstream pull request for it.
Context: the issue's maintainer triage (#5936 (comment)) labeled it ready-for-pr as a restore-class fix and asked that host allowance derive from registered project origins or configured GitHub hosts rather than accepting any host, and that the host be carried through bin/fm-pr-merge.sh.
Fixes #5936
What Changed
config/github-hosts, while rejecting unlisted hosts.GH_HOST.Known follow-ups
tasks-axichange in fix: accept GitHub Enterprise pull request URLs tasks-axi#77 .tasks-axivalidates the--prlink itself and rejects a singular/pull/route outside github.com, so nothing here vendors, patches, or works around it. Until that change lands, a merged Enterprise PR keeps the existing retained pending-close record: teardown records what it owes before any destructive step, the rejected link leaves that record and the backlog row untouched, and the same record closes normally once the link is accepted. Verified against the installedtasks-axiwith a real pending-close record.Risk Assessment
Medium: the code change is confined to GitHub host acceptance and host routing, and github.com behavior is unchanged. The two residual risks are both documented above rather than fixed here: backlog-close linking for an Enterprise URL waits on the companion
tasks-axichange, and polls armed before this update are invalidated by the static-template change exactly as any earlier template change invalidated them.Testing
Live read-only registration, merged polling, notification persistence, and merge-preflight refusal passed against Enterprise PR 505. CLI transcripts and persisted-state evidence were captured; fixtures were removed. No actual merge, broad suite, lint, or static analysis was run.
Evidence: Live registration and forge reads
Source: Live registration and forge reads
Evidence: Persisted Enterprise identity and real head SHA
Source: Persisted Enterprise identity and real head SHA
Evidence: Live poll prints merged
Source: Live poll prints merged
Evidence: Notification publication returns zero
Source: Notification publication returns zero
Evidence: Durable wake and Enterprise notification marker
Source: Durable wake and Enterprise notification marker
Evidence: Live merge refusal and host-specific preflight reads
Source: Live merge refusal and host-specific preflight reads
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-lib.sh:271- The intent requires Enterprise PRs to be “linked when its backlog item closes”, but the newFM_PR_HOST=$hostacceptance leaves that failure unresolved. For a merged Enterprise PR, teardown passes--pr <enterprise-url>throughfm_backlog_doneunchanged; supported tasks-axi 0.2.6 rejects its singular/pull/route outside github.com. Normal closure, retained artifacts, and pending-close replay remain affected (bin/fm-backlog-transition-lib.sh:533, :552, :1221). Complete the shared backlog adaptation or require a dependency that supports these links.bin/fm-pr-lib.sh:222- With FM_HOME and FM_CONFIG_OVERRIDE unset, this resolves to/config/github-hosts, ignoring the documented default home. Both standalone consumers, bin/fm-pr-state.sh:64 and bin/fm-pr-reviewers.sh:51, initialize neither variable before parsing, so they reject Enterprise hosts configured under the repository's config directory. Apply the normal home fallback before reading the allowlist.bin/fm-pr-poll.sh:61- Updating this static template invalidates every previously armed merge poll, including other providers. Their saved check files contain the old bytes, while bin/fm-pr-lib.sh:761 requires equality with the current template. The watcher then rejects those registrations at bin/fm-watch.sh:2987 instead of checking merges; the update path does not refresh them. Republish existing authenticated registrations through the existing publication helpers when updating the template, preserving tamper checks.🔧 Fix applied.
2 issues (1 error, 1 warning) still open:
bin/fm-pr-lib.sh:271- The intent requires Enterprise PRs to be “linked when its backlog item closes”, but the newFM_PR_HOST=$hostacceptance leaves that failure unresolved. For a merged Enterprise PR, teardown passes--pr <enterprise-url>throughfm_backlog_doneunchanged; supported tasks-axi 0.2.6 rejects its singular/pull/route outside github.com. Normal closure, retained artifacts, and pending-close replay remain affected (bin/fm-backlog-transition-lib.sh:533, :552, :1221). Complete the shared backlog adaptation or require a dependency that supports these links.bin/fm-pr-poll.sh:61- Updating this static template invalidates every previously armed merge poll, including other providers. Their saved check files contain the old bytes, while bin/fm-pr-lib.sh:761 requires equality with the current template. The watcher then rejects those registrations at bin/fm-watch.sh:2987 instead of checking merges; the update path does not refresh them. Republish existing authenticated registrations through the existing publication helpers when updating the template, preserving tamper checks.bash tests/.gate-ghe-selected.sh: parser matrix, Enterprise config resolution, Enterprise registration/poll/merge routing, invalid-entrypoint side effects, recording/merge derivation, and static poll behaviorbash tests/fm-pr-state.test.shbash tests/fm-pr-reviewers.test.shpython3 .test-ghe-gate/live-checks.py: actual entrypoints and real gh with isolated home/config; reproduction driver retained in the evidence directoryRemoved temporary validation drivers and fixtures;git status --shortwas clean🔧 No changes applied.
1 info still open:
bash -x bin/fm-pr-check.sh scratch-ghe-505 https://leadsonline.ghe.com/LeadsOnline/nighthawk-tf/pull/505with isolated FM_HOME and a one-host allowlistExecuted the generatedscratch-ghe-505.check.shwith real gh; asserted stdout was exactlymerged\n.Sourced the specified libraries and calledfm_merge_outcome_report; verified return zero, durable wake, and Enterprise identity marker.FM_PR_GITHUB_MERGEABLE_RETRY_DELAY=0 bash -x bin/fm-pr-merge.sh scratch-ghe-505 https://leadsonline.ghe.com/LeadsOnline/nighthawk-tf/pull/505; verified live state MERGED, mergeability UNKNOWN, Enterprise preflight commands, and no gh pr merge invocation.Inspected persisted registration records, removed the disposable driver and home, and confirmedgit status --shortwas empty.✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → no changes applied ✅
🔧 No changes applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.