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): parse GitLab remote host/path robustly (numeric namespace, IPv6 host)
[._.]/ Adam Eivyb007db08a1ea
diff --git a/server/services/perpetualWork.js b/server/services/perpetualWork.jsindex 20192c0c48..2ba3b0b99b 100644--- a/server/services/perpetualWork.js+++ b/server/services/perpetualWork.js@@ -88,18 +88,25 @@ export function issueNumberFromRef(ref) {async function resolveGitlabNamespace(repoPath) {const url = await readOriginRemoteUrl(repoPath).catch(() => null);if (typeof url !== 'string' || !url.trim()) return null;- // Strip `scheme://`, an optional `user@`, and a trailing `.git`, then split off- // the host (the segment before the first ':' or '/') to leave the repo path.- const afterHostPrefix = url.trim()- .replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//, '')- .replace(/^[^@/]+@/, '')- .replace(/\.git$/i, '');- const sepIdx = afterHostPrefix.search(/[:/]/);- if (sepIdx === -1) return null;- const rawPath = afterHostPrefix.slice(sepIdx + 1)- .replace(/^\/+/, '') // strip leading slash(es) after `host:` / `host/`- .replace(/^\d+\//, ''); // strip an SSH `host:443/owner/repo` port hop- const segments = rawPath.split('/').filter(Boolean);+ const trimmed = url.trim().replace(/\.git$/i, '');+ // Extract the repo PATH (everything after the host) without mistaking any of the+ // host for it. A `[^/]+` host run stops at the path's first slash — and since a+ // host (bracketed IPv6 included) contains no slash, this isolates the path even+ // for `[2001:db8::1]/group/repo` and keeps a `:port` with the host. No numeric+ // segment is ever stripped from the path, so a numeric GitLab namespace+ // (`/1234/repo`) survives intact.+ let rawPath = null;+ const urlStyle = trimmed.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/(?:[^@/]+@)?[^/]+\/(.+)$/);+ if (urlStyle) {+ rawPath = urlStyle[1]; // scheme://[user@]host[:port]/PATH+ } else {+ // scp-style SSH: [user@]host:PATH — the host may be a bracketed IPv6 literal+ // (whose inner colons must NOT be read as the host/path separator).+ const scpStyle = trimmed.match(/^(?:[^@]+@)?(?:\[[^\]]+\]|[^:]+):(.+)$/);+ if (!scpStyle) return null;+ rawPath = scpStyle[1];+ }+ const segments = rawPath.replace(/^\/+/, '').split('/').filter(Boolean);if (segments.length < 2) return null; // need at least namespace + reposegments.pop(); // drop the repo segment; the rest is the (possibly nested) namespacereturn segments.join('/');diff --git a/server/services/perpetualWork.test.js b/server/services/perpetualWork.test.jsindex 9657d0f352..80d9f5c8fc 100644--- a/server/services/perpetualWork.test.js+++ b/server/services/perpetualWork.test.js@@ -480,6 +480,37 @@ describe('perpetualWork', () => {expect(issueCalls.every(([, a]) => !a.includes('--author'))).toBe(true);});+ it('preserves a numeric namespace in an HTTPS remote (does not strip it as a port hop)', async () => {+ // Regression: an all-numeric top-level namespace (`/1234/widget`) must NOT be+ // mistaken for an SSH `:443/` port hop and dropped — GitLab numeric group/user+ // paths are valid, so the probe must target groups/1234.+ spawn.mockImplementation((cmd, args = []) => {+ if (cmd === 'git' && args[0] === 'remote') return fakeChild('https://gitlab.example/1234/widget.git\n');+ if (cmd === 'glab' && args[0] === 'api' && String(args[1]).startsWith('groups/')) return fakeChild('{"kind":"group"}');+ if (cmd === 'glab' && args[0] === 'issue') return fakeChild(JSON.stringify([{ iid: 3, title: 'x', assignees: [], labels: [] }]));+ return fakeChild('');+ });+ const out = await detectGitlabIssues(app, { issueAuthorFilter: 'owner' });+ expect(out).toMatchObject({ reason: 'owner-is-group', total: 1 });+ const probeCall = spawn.mock.calls.find(([cmd, a]) => cmd === 'glab' && a[0] === 'api' && String(a[1]).startsWith('groups/'));+ expect(probeCall[1][1]).toBe('groups/1234');+ });++ it('parses a bracketed IPv6 host without leaking the address into the namespace', async () => {+ // Regression: the host/path split must not trip on the colons inside a+ // bracketed IPv6 literal — the namespace is `group`, not part of the address.+ spawn.mockImplementation((cmd, args = []) => {+ if (cmd === 'git' && args[0] === 'remote') return fakeChild('https://[2001:db8::1]/group/widget.git\n');+ if (cmd === 'glab' && args[0] === 'api' && String(args[1]).startsWith('groups/')) return fakeChild('{"kind":"group"}');+ if (cmd === 'glab' && args[0] === 'issue') return fakeChild(JSON.stringify([{ iid: 4, title: 'x', assignees: [], labels: [] }]));+ return fakeChild('');+ });+ const out = await detectGitlabIssues(app, { issueAuthorFilter: 'owner' });+ expect(out).toMatchObject({ reason: 'owner-is-group', total: 1 });+ const probeCall = spawn.mock.calls.find(([cmd, a]) => cmd === 'glab' && a[0] === 'api' && String(a[1]).startsWith('groups/'));+ expect(probeCall[1][1]).toBe('groups/group');+ });+it('owner filter on a USER-owned project passes --author <namespace> (groups probe 404)', async () => {// A user namespace: `glab api groups/<namespace>` 404s (non-zero exit) → not// a group, so owner-mode filters by the namespace login as before.