{"record":{"id":"34c2e237a0059306","repo":"jackwener/OpenCLI","slug":"opencli-data-uri-was-intercepted-updated-url","errorCode":null,"errorMessage":"[opencli] data: URI was intercepted (${updated.url}), creating fresh tab","messagePattern":"\\[opencli\\] data: URI was intercepted \\((.+?)\\), creating fresh tab","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extension/src/background.ts","lineNumber":1582,"sourceCode":"  const role = getOwnedWindowRole(leaseKey);\n  const group = existingSession?.owned ? await ensureOwnedContainerGroup(role, windowId, []) : null;\n  const scopedWindowId = group?.windowId ?? windowId;\n  const reusableTabId = await findReusableOwnedContainerTab(scopedWindowId, existingSession?.owned ? (group?.id ?? null) : undefined);\n  if (reusableTabId !== undefined) return { tabId: reusableTabId, tab: await chrome.tabs.get(reusableTabId) };\n\n  // No debuggable tab — another extension may have hijacked the tab URL.\n  // Only recycle arbitrary tabs for legacy unscoped sessions. Owned sessions\n  // without a group signal must create a fresh tab rather than overwrite user\n  // content in a window where an OpenCLI group may have disappeared.\n  const tabs = await chrome.tabs.query({ windowId: scopedWindowId });\n  const reuseTab = existingSession?.owned ? undefined : tabs.find(t => t.id);\n  if (reuseTab?.id) {\n    await chrome.tabs.update(reuseTab.id, { url: BLANK_PAGE });\n    await new Promise(resolve => setTimeout(resolve, 300));\n    try {\n      const updated = await chrome.tabs.get(reuseTab.id);\n      if (isDebuggableUrl(updated.url)) return { tabId: reuseTab.id, tab: updated };\n      console.warn(`[opencli] data: URI was intercepted (${updated.url}), creating fresh tab`);\n    } catch {\n      // Tab was closed during navigation\n    }\n  }\n\n  // Fallback: create a new tab\n  const newTab = await chrome.tabs.create({ windowId: scopedWindowId, url: BLANK_PAGE, active: true });\n  if (!newTab.id) throw new Error('Failed to create tab in automation container');\n  await ensureOwnedContainerGroup(role, scopedWindowId, [newTab.id]);\n  return { tabId: newTab.id, tab: await chrome.tabs.get(newTab.id) };\n}\n\n/** Build a page-scoped success result with targetId resolved from tabId */\nasync function pageScopedResult(id: string, tabId: number, data?: unknown): Promise<Result> {\n  const page = await identity.resolveTargetId(tabId);\n  return { id, ok: true, data, page };\n}\n","sourceCodeStart":1564,"sourceCodeEnd":1600,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/extension/src/background.ts#L1564-L1600","documentation":"A console warning emitted when a reused tab was navigated to a blank page but, after re-fetching, its URL is still not debuggable — typically because the browser intercepted or transformed the navigation (e.g. a data: URI landed as the tab's URL or was blocked). The extension logs this and falls back to creating a fresh tab.","triggerScenarios":"During tab creation with reuse, chrome.tabs.update to BLANK_PAGE completes but the resulting updated.url fails isDebuggableUrl — e.g. a data: URI was intercepted, a redirect chain ends on a non-debuggable page, or a site error page replaced the blank document.","commonSituations":"Navigating to data: URIs that Chrome blocks or wraps; extension interference with navigation; error/interstitial pages replacing the blank target.","solutions":["Nothing needed — the extension automatically creates a fresh tab as fallback","Avoid targeting data: URIs; serve content over http(s) instead","Reload the interfering extensions or test in a clean profile","Update Chrome if a newer build handles the navigation correctly"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const updated = await chrome.tabs.get(reuseTab.id);\nif (!isDebuggable(updated.url)) await createFreshTab();","typeGuard":"const isDebuggable = (url) => typeof url === 'string' && /^https?:\\/\\//.test(url);","tryCatchPattern":null,"preventionTips":["Avoid data: URIs as navigation targets","Serve test content over http(s)","Disable interfering extensions during automation"],"tags":["chrome-extension","navigation","tab-management"],"backgroundTag":"data-uri-intercepted","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}