{"record":{"id":"1c1b8d36ab8b7eba","repo":"can1357/oh-my-pi","slug":"imageselectormessage-the-img-selector-only-s","errorCode":null,"errorMessage":"imageSelectorMessage = \"The ':img' selector only supports local .svg and .svgz files.\"","messagePattern":"imageSelectorMessage = \"The ':img' selector only supports local \\.svg and \\.svgz files\\.\"","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/read.ts","lineNumber":1172,"sourceCode":"\t\t\t? await this.#tryReadDelimitedPaths(readPath, signal, entry => internalRouter.canResolve(entry))\n\t\t\t: null;\n\t\tif (delimitedInternalResult) return delimitedInternalResult;\n\n\t\t// Peel malformed selectors through the internal-URL-aware parser before routing.\n\t\tlet promotedSelector: string | undefined;\n\t\tif (internalRouter.canResolve(readPath)) {\n\t\t\tconst internalTarget = splitInternalUrlSel(readPath);\n\t\t\tconst parsed = parseSel(internalTarget.sel);\n\t\t\tif (internalTarget.sel !== undefined && parsed.kind === \"none\") {\n\t\t\t\tthrow new ToolError(\n\t\t\t\t\t`Invalid selector ':${internalTarget.sel}' on '${internalTarget.path}'. Use :N, :N-M, :N+K, :N- (open-ended), a comma-separated list of ranges, :raw, :img for SVG rendering, or a range combined with raw (e.g. :raw:50-100).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst urlMeta = parseInternalUrl(internalTarget.path);\n\t\t\tconst scheme = urlMeta.protocol.replace(/:$/, \"\").toLowerCase();\n\t\t\tconst imageSelectorMessage = \"The ':img' selector only supports local .svg and .svgz files.\";\n\t\t\tif (parsed.kind === \"image\" && scheme !== \"local\") {\n\t\t\t\tthrow new ToolError(imageSelectorMessage);\n\t\t\t}\n\t\t\tif (scheme === \"local\") {\n\t\t\t\tconst localFile = await resolveLocalUrlToFile(urlMeta, {\n\t\t\t\t\tcwd: this.session.cwd,\n\t\t\t\t\tsettings: this.session.settings,\n\t\t\t\t\tsignal,\n\t\t\t\t\tlocalProtocolOptions: this.session.localProtocolOptions,\n\t\t\t\t\tskills: this.session.skills,\n\t\t\t\t});\n\t\t\t\tif (localFile) {\n\t\t\t\t\treadPath = localFile.path;\n\t\t\t\t\t// Preserve a local:// selector separately so a sibling literal file\n\t\t\t\t\t// cannot shadow the URL's selector semantics during filesystem routing.\n\t\t\t\t\tpromotedSelector = internalTarget.sel;\n\t\t\t\t} else {\n\t\t\t\t\tif (parsed.kind === \"image\") throw new ToolError(imageSelectorMessage);\n\t\t\t\t\treturn this.#handleInternalUrl(internalTarget.path, parsed, signal);\n\t\t\t\t}","sourceCodeStart":1154,"sourceCodeEnd":1190,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/read.ts#L1154-L1190","documentation":"The ':img' selector asks ReadTool to render an image, but it is only implemented for local SVG/SVGZ files. When the parsed selector is kind 'image' and the target URL's scheme is not 'local', the tool throws immediately rather than attempting remote rendering.","triggerScenarios":"Reading an internal-scheme URL (e.g. agent://, https-like internal resources) or any non-local:// target with an ':img' suffix, e.g. 'agent://skill/foo:img'.","commonSituations":"Trying to get a rendered view of a remote or generated SVG via an internal URL scheme, or appending ':img' by habit to any URL the agent reads.","solutions":["Use a local:// URL pointing at an actual .svg or .svgz file when using ':img'.","Drop the ':img' selector and read the resource as text/raw instead.","Copy or download the SVG to a local file first, then read it with ':img'."],"exampleFix":"// before\nread(\"agent://diagram:img\")\n// after\nread(\"local:///tmp/diagram.svg:img\")","handlingStrategy":"validation","validationCode":"if (sel === 'img' && !url.startsWith('local://')) throw new Error(':img requires a local:// .svg/.svgz target');","typeGuard":"function canUseImgSelector(url) { return url.startsWith('local://') && /\\.svgz?$/i.test(url.split(':img')[0]); }","tryCatchPattern":"try { return await read(url) } catch (e) { if (String(e.message).includes(':img')) { return await read(url.replace(':img','')); } throw e; }","preventionTips":["Attach :img only to local:// URLs ending in .svg or .svgz","Check the URL scheme before adding render selectors","Fall back to :raw for non-local resources"],"tags":["read-tool","svg","selector-syntax"],"backgroundTag":"img-selector-unsupported-target","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}