{"record":{"id":"0e2ff64b8fd98889","repo":"garrytan/gstack","slug":"cannot-save-domain-skill-no-top-level-url-on-acti","errorCode":null,"errorMessage":"Cannot save domain-skill: no top-level URL on active tab.\nCause: tab is empty or on chrome:// page.\nAction: navigate to the target site first with $B goto <url>.","messagePattern":"Cannot save domain-skill: no top-level URL on active tab\\.\nCause: tab is empty or on chrome:// page\\.\nAction: navigate to the target site first with \\$B goto <url>\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/domain-skills.ts","lineNumber":100,"sourceCode":"  h = h.replace(/^https?:\\/\\//, '');\n  // strip path/query\n  h = h.split('/')[0]!.split('?')[0]!.split('#')[0]!;\n  // strip port\n  h = h.split(':')[0]!;\n  // strip www. prefix\n  h = h.replace(/^www\\./, '');\n  return h;\n}\n\n/**\n * Derive hostname from the active tab's top-level origin.\n * Closes the confused-deputy bug (Codex T3): agent cannot supply a wrong\n * hostname even if it tried — host is read from the page state we control.\n */\nexport async function deriveHostFromActiveTab(page: Page): Promise<string> {\n  const url = page.url();\n  if (!url || url === 'about:blank' || url.startsWith('chrome://')) {\n    throw new Error(\n      'Cannot save domain-skill: no top-level URL on active tab.\\n' +\n        'Cause: tab is empty or on chrome:// page.\\n' +\n        'Action: navigate to the target site first with $B goto <url>.'\n    );\n  }\n  return normalizeHost(url);\n}\n\n// ─── File I/O (T5: append-only + flock-free atomic appends) ────\n\nasync function ensureDir(filePath: string): Promise<void> {\n  await fs.mkdir(path.dirname(filePath), { recursive: true });\n}\n\n/**\n * Append a JSONL row atomically. POSIX guarantees atomicity for writes <\n * PIPE_BUF (typically 4KB) when O_APPEND is set. Each row is single-line JSON\n * well under that bound. fsync ensures durability before return.","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/domain-skills.ts#L82-L118","documentation":"Error \"Cannot save domain-skill: no top-level URL on active tab.\nCause: tab is empty or on chrome:// page.\nAction: navigate to the target site first with $B goto <url>.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/domain-skills.ts:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}