Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): canonicalize the ssh.github.com alias for the PR-watcher self-login
[._.]/ Adam Eivy78470776278e
diff --git a/server/lib/workTracker.js b/server/lib/workTracker.jsindex 910c988acd..3dedc19538 100644--- a/server/lib/workTracker.js+++ b/server/lib/workTracker.js@@ -90,8 +90,25 @@ export function isGithubHost(host) {*/export function githubRepoSpec(origin) {if (!origin?.fullName || !isGithubHost(origin.host)) return null;- const apiHost = /^ssh\.github\.com$/i.test(origin.host) ? 'github.com' : origin.host;- return `${apiHost}/${origin.fullName}`;+ return `${githubApiHost(origin.host)}/${origin.fullName}`;+}++/**+ * Canonicalize a GitHub origin host to the API host `gh --hostname` / `gh --repo`+ * expects. GitHub's SSH-over-443 alias (`[email protected]:443/owner/repo`) parses+ * to host `ssh.github.com`, but the API endpoint is `github.com` — querying+ * `ssh.github.com` as an API host silently fails. Only `github.com` has a documented+ * `ssh.` alias, so canonicalize the exact known alias and pass every other host+ * (github.com, `ssh.github.acme.example`, and other enterprise hosts) through+ * unchanged. Callers that hand a host to a `gh` `--hostname` (e.g. prWatcher's+ * `getSelfLogin`) MUST canonicalize through here, or an ssh-alias origin resolves+ * the wrong API host — the same trap `githubRepoSpec` avoids for the repo selector.+ * @param {string|null|undefined} host+ * @returns {string|null}+ */+export function githubApiHost(host) {+ if (!host) return null;+ return /^ssh\.github\.com$/i.test(host) ? 'github.com' : host;}/**diff --git a/server/lib/workTracker.test.js b/server/lib/workTracker.test.jsindex 99009cb6e8..66fd928b31 100644--- a/server/lib/workTracker.test.js+++ b/server/lib/workTracker.test.js@@ -7,6 +7,7 @@ import {hostToWorkTracker,isGithubHost,githubRepoSpec,+ githubApiHost,forgeCliForTracker,trackerToClaimTaskType,resolveWorkTracker,@@ -87,6 +88,26 @@ describe('githubRepoSpec', () => {});});+describe('githubApiHost', () => {+ it('canonicalizes the documented github.com SSH-over-443 alias to github.com (#2650)', () => {+ // prWatcher hands this host to getSelfLogin's `gh --hostname`; a raw+ // ssh.github.com would query the SSH endpoint and always return null,+ // wedging every self/others PR gate into self-login-unavailable.+ expect(githubApiHost('ssh.github.com')).toBe('github.com');+ expect(githubApiHost('SSH.GitHub.com')).toBe('github.com');+ });+ it('passes github.com and enterprise hosts (including a genuine ssh.* one) through unchanged', () => {+ expect(githubApiHost('github.com')).toBe('github.com');+ expect(githubApiHost('github.acme.example')).toBe('github.acme.example');+ expect(githubApiHost('ssh.github.acme.example')).toBe('ssh.github.acme.example');+ });+ it('returns null for a falsy host', () => {+ expect(githubApiHost(null)).toBeNull();+ expect(githubApiHost(undefined)).toBeNull();+ expect(githubApiHost('')).toBeNull();+ });+});+describe('forgeCliForTracker', () => {it('maps forge trackers to their CLI, others to null', () => {expect(forgeCliForTracker('github')).toBe('gh');diff --git a/server/services/prWatcher.js b/server/services/prWatcher.jsindex fef32f3d54..f2254e0274 100644--- a/server/services/prWatcher.js+++ b/server/services/prWatcher.js@@ -27,7 +27,7 @@import { execGh } from './github.js';import { getAppById, updateApp } from './apps.js';import { getOriginInfo } from '../lib/gitRemote.js';-import { githubRepoSpec } from '../lib/workTracker.js';+import { githubRepoSpec, githubApiHost } from '../lib/workTracker.js';import { PR_AUTHOR_FILTERS } from '../lib/validation.js';import { safeJSONParse } from '../lib/fileUtils.js';@@ -214,7 +214,11 @@ export async function checkPullRequests(app, { authorFilter = 'any' } = {}) {// blindly if gh can't tell us who "self" is on THIS repo's host.let selfLogin = null;if (filter !== 'any') {- selfLogin = await getSelfLogin(origin.host);+ // Canonicalize the host: an `ssh.github.com` alias origin must resolve "self"+ // against the github.com API host, matching githubRepoSpec's repo selector.+ // Passing origin.host raw would query the SSH endpoint and always return+ // self-login-unavailable, so self/others gates would never fire (#2650).+ selfLogin = await getSelfLogin(githubApiHost(origin.host));if (!selfLogin) {return { ok: false, reason: 'self-login-unavailable', repoFullName, defaultBranch };}