{"record":{"id":"edcbb07c457b0d5e","repo":"can1357/oh-my-pi","slug":"host-uri-read-failed-for-url-href","errorCode":null,"errorMessage":"Host URI read failed for ${url.href}","messagePattern":"Host URI read failed for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/rpc/host-uris.ts","lineNumber":157,"sourceCode":"\t\tif (!pending) return false;\n\t\tthis.#pending.delete(frame.id);\n\t\tpending.resolve(frame);\n\t\treturn true;\n\t}\n\n\trejectAllPending(message: string): void {\n\t\tconst error = new Error(message);\n\t\tconst pending = Array.from(this.#pending.values());\n\t\tthis.#pending.clear();\n\t\tfor (const entry of pending) {\n\t\t\tentry.reject(error);\n\t\t}\n\t}\n\n\tasync requestRead(scheme: string, url: InternalUrl, context?: ResolveContext): Promise<InternalResource> {\n\t\tconst result = await this.#dispatch(\"read\", url.href, undefined, context?.signal);\n\t\tif (result.isError) {\n\t\t\tthrow new Error(result.error || result.content || `Host URI read failed for ${url.href}`);\n\t\t}\n\t\tconst content = result.content ?? \"\";\n\t\tconst contentType = result.contentType ?? \"text/plain\";\n\t\tconst definition = this.#definitions.get(scheme);\n\t\treturn {\n\t\t\turl: url.href,\n\t\t\tcontent,\n\t\t\tcontentType,\n\t\t\tsize: Buffer.byteLength(content, \"utf-8\"),\n\t\t\tnotes: result.notes && result.notes.length > 0 ? [...result.notes] : undefined,\n\t\t\timmutable: result.immutable ?? definition?.immutable === true,\n\t\t};\n\t}\n\n\tasync requestWrite(_scheme: string, url: InternalUrl, content: string, context?: WriteContext): Promise<void> {\n\t\tconst result = await this.#dispatch(\"write\", url.href, content, context?.signal);\n\t\tif (result.isError) {\n\t\t\tthrow new Error(result.error || result.content || `Host URI write failed for ${url.href}`);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/rpc/host-uris.ts#L139-L175","documentation":"requestRead dispatches a read to the scheme's registered handler via RPC and, if the handler replies with isError or returns neither error nor content, throws 'Host URI read failed for <url>'. The remote read result was an error (or empty), so no resource can be returned.","triggerScenarios":"Calling requestRead(scheme, url) where the dispatched handler responds with result.isError === true (result.error/content used as the message), or returns an empty result with no error text or content for the given URL.","commonSituations":"The host-side handler for the scheme cannot read the target (missing file, permission denied, remote service down); the handler crashed and returned an empty/undefined result; the URL points to a resource that no longer exists.","solutions":["Read the underlying handler error — the thrown message uses result.error || result.content, so capture it (catch and inspect message/cause) for the real cause","Verify the URL target exists and the host process can access it (permissions, path validity)","Check that the scheme handler is correctly registered and functioning on the host side (setSchemes/dispatch wiring)","Retry if the failure was transient (network/remote service); otherwise surface the handler error to the user"],"exampleFix":"// before\nconst resource = await hostUris.requestRead(scheme, url);\n// after\nlet resource;\ntry {\n  resource = await hostUris.requestRead(scheme, url);\n} catch (e) {\n  logger.warn(\"Host URI read failed\", { url: url.href, error: String(e) });\n  resource = fallbackResource; // or re-throw after logging\n}","handlingStrategy":"try-catch","validationCode":"const def = hostUris.getScheme?.(scheme); // ensure a handler is registered\nif (!def) throw new Error(`No handler registered for scheme: ${scheme}`);\nawait assertUrlReachable(url.href); // app-specific preflight, if available","typeGuard":null,"tryCatchPattern":"try {\n  const resource = await hostUris.requestRead(scheme, url, ctx);\n} catch (err) {\n  if (err.message.startsWith(\"Host URI read failed\")) {\n    // message body carries the handler's error/content — surface it\n    ui.showError(`Could not read ${url.href}: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Verify the scheme handler is registered and healthy before dispatching reads","Validate/normalize URLs against the scheme's expected shape","Add timeouts + bounded retries for transient remote-read failures","Log the handler's error/content (embedded in the thrown message) for diagnosis"],"tags":["rpc","host-uri","read-failed","remote"],"backgroundTag":"host-uri-read-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}