Skip to content

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

fix: recognize two more GHES gh-probe failure shapes instead of a generic error

Adam Eivy8e4a3e834128
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 92e073ec84..0ec0d7f811 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -32,6 +32,8 @@
- **[issue-3704] The UI no longer goes blank when iCloud offloads a synced file** — macOS "Optimize Mac Storage" can evict MortalLoom and Obsidian files to the cloud. Reading one of those offloaded files used to stall indefinitely, and a handful of stalls was enough to freeze every page in PortOS while the server still looked healthy — pages simply never loaded and only a restart brought them back. PortOS now detects an offloaded file up front, skips the read, asks iCloud to download it in the background, and reports "temporarily unavailable" for just that record until it arrives.
+- **A managed app tracking issues on a self-hosted GitHub Enterprise instance no longer reports the unhelpful "gh failed for an unrecognised reason" on the Issues tab.** The `gh` reachability probe already targeted the app's actual forge host correctly, but two of that host's own failure shapes weren't in the classifier's marker lists, so both fell through to the generic, unhelpful catch-all instead of an accurate status: a DNS or connectivity failure now prints gh's own wrapper text ("error connecting to `<host>`") rather than the raw Go transport errors (`dial tcp`, `connection refused`, …) the markers were written against; and many GitHub Enterprise Server installs disable the `/rate_limit` endpoint the probe deliberately targets for its free quota cost, which made a perfectly reachable, correctly authenticated host fail the health gate on "HTTP 404: Rate limiting is not enabled" before the Issues tab ever tried to list anything. Both are now recognized — the first as "unreachable" with its existing remedy, the second as healthy, since a 404 from that specific endpoint is proof the forge answered.
+
- **[issue-3706] Saving a note that iCloud has offloaded no longer risks freezing the UI.** [issue-3704] stopped offloaded files from stalling PortOS when they were *read*, but saving over one was still unguarded — and measuring it showed that overwriting an offloaded note stalls exactly like reading it, even though the save replaces every byte of the file. That matters more than a manual save: your Brain daily-log mirror and YouTube transcript ingest write notes on their own schedule, so a stuck iCloud could have frozen every page with nobody at the keyboard. PortOS now checks before saving, asks iCloud for the note and waits briefly, and if it still hasn't arrived reports "temporarily unavailable" for that one note — leaving its existing contents untouched — instead of hanging. Background mirrors skip that note quietly and pick it up on their next pass.
- **[issue-3706] Re-ingesting a YouTube video no longer loses track of its existing vault note.** If the note had been offloaded by iCloud, the mirror was skipped — and the skip was recorded as "this video has no note", which stranded the existing note where deleting the ingest could never clean it up, and made the next re-ingest create a second note at a fresh date. A skipped mirror now keeps the existing note's location and simply retries next time.
diff --git a/server/services/github.ghHealth.test.js b/server/services/github.ghHealth.test.js
index 0dacff44b6..4fe36e2e9f 100644
--- a/server/services/github.ghHealth.test.js
+++ b/server/services/github.ghHealth.test.js
@@ -72,6 +72,19 @@ describe('classifyGhProbe', () => {
expect(classifyGhProbe({ code: 1, stderr }).status).toBe(expected);
});
+ it('classifies gh 2.9x\'s own DNS/connect-failure wrapper as unreachable, not a generic error', () => {
+ // Reproduced against a real gh 2.96.0 binary probing an unresolvable
+ // `--hostname` — the exact shape a misconfigured or unreachable self-hosted
+ // GitHub Enterprise host produces. This text carries none of the raw Go
+ // transport strings above, so it was falling into the unhelpful 'error'
+ // catch-all ("gh failed for an unrecognised reason").
+ const probe = classifyGhProbe({
+ code: 1,
+ stderr: 'error connecting to github.enterprise.example\ncheck your internet connection or https://githubstatus.com'
+ });
+ expect(probe.status).toBe('unreachable');
+ });
+
it.each([
'You are not logged in to any GitHub hosts. To log in, run: gh auth login',
'HTTP 401: Bad credentials (https://api.github.com/rate_limit)',
@@ -100,6 +113,19 @@ describe('classifyGhProbe', () => {
it('does not collapse an unrecognised failure into ok', () => {
expect(classifyGhProbe({ code: 1, stderr: 'something new' }).status).toBe('error');
});
+
+ it('treats a GHES host with rate limiting disabled as ok, not error', () => {
+ // Reproduced against a real GitHub Enterprise Server host with the
+ // /rate_limit endpoint turned off: `gh api rate_limit --hostname <ghes>`
+ // exits 1 with this exact message even though gh authenticated and
+ // reached the host fine. That proves reachability — it must not be
+ // reported as "gh failed for an unrecognised reason".
+ const probe = classifyGhProbe({
+ code: 1,
+ stderr: 'HTTP 404: Rate limiting is not enabled. (https://github.enterprise.example/api/v3/rate_limit)'
+ });
+ expect(probe).toEqual({ status: 'ok', detail: null });
+ });
});
describe('ghRemedy', () => {
diff --git a/server/services/github.js b/server/services/github.js
index 66eed6560d..90624392ab 100644
--- a/server/services/github.js
+++ b/server/services/github.js
@@ -365,11 +365,32 @@ const GH_NETWORK_MARKERS = [
'i/o timeout',
'timed out',
'tls handshake',
- 'certificate'
+ 'certificate',
+ // gh's own DNS/connect-failure wrapper (seen on gh 2.9x), distinct from the
+ // raw Go transport strings above — this is what a `--hostname` pointed at an
+ // unreachable or misresolved self-hosted GitHub Enterprise instance actually
+ // prints, and it was falling through to the generic 'error' bucket.
+ 'error connecting to'
];
const includesAny = (haystack, needles) => needles.some(n => haystack.includes(n));
+// GitHub Enterprise Server admins can disable the `/rate_limit` endpoint
+// outright (a documented GHES setting) — `gh api rate_limit` then fails with
+// "HTTP 404: Rate limiting is not enabled" even though `gh` successfully
+// authenticated and round-tripped to that host. This bucket is only valid
+// because probeGh is classifyGhProbe's one caller and always hits
+// `/rate_limit` (see probeGh) — that response is proof the forge IS
+// reachable, not evidence it is not. Without this marker it fell into the
+// generic 'error' bucket ("gh failed for an unrecognised reason"), so a
+// perfectly healthy GHES install with rate limiting turned off never got
+// past the health gate to list PRs/issues. If classifyGhProbe ever gains a
+// second caller probing a different endpoint, move this bucket into probeGh
+// so it stays scoped to the endpoint it actually describes.
+const GH_RATE_LIMIT_DISABLED_MARKERS = [
+ 'rate limiting is not enabled'
+];
+
/**
* Classify a `gh` probe result. Split out from the spawn so the mapping from
* failure text to status is testable without a network or a `gh` binary.
@@ -389,6 +410,7 @@ export function classifyGhProbe({ code = null, stderr = '', spawnError = null }
const text = String(stderr || '').trim();
const lower = text.toLowerCase();
if (includesAny(lower, GH_AUTH_MARKERS)) return { status: 'not-authenticated', detail: text || null };
+ if (includesAny(lower, GH_RATE_LIMIT_DISABLED_MARKERS)) return { status: 'ok', detail: null };
if (includesAny(lower, GH_NETWORK_MARKERS)) return { status: 'unreachable', detail: text || null };
return { status: 'error', detail: text || `gh exited with code ${code}` };
}