can1357/oh-my-pi · error · ToolError
imageSelectorMessage = "The ':img' selector only supports lo
Error message
imageSelectorMessage = "The ':img' selector only supports local .svg and .svgz files."
What it means
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.
Source
Thrown at packages/coding-agent/src/tools/read.ts:1172
? await this.#tryReadDelimitedPaths(readPath, signal, entry => internalRouter.canResolve(entry))
: null;
if (delimitedInternalResult) return delimitedInternalResult;
// Peel malformed selectors through the internal-URL-aware parser before routing.
let promotedSelector: string | undefined;
if (internalRouter.canResolve(readPath)) {
const internalTarget = splitInternalUrlSel(readPath);
const parsed = parseSel(internalTarget.sel);
if (internalTarget.sel !== undefined && parsed.kind === "none") {
throw new ToolError(
`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).`,
);
}
const urlMeta = parseInternalUrl(internalTarget.path);
const scheme = urlMeta.protocol.replace(/:$/, "").toLowerCase();
const imageSelectorMessage = "The ':img' selector only supports local .svg and .svgz files.";
if (parsed.kind === "image" && scheme !== "local") {
throw new ToolError(imageSelectorMessage);
}
if (scheme === "local") {
const localFile = await resolveLocalUrlToFile(urlMeta, {
cwd: this.session.cwd,
settings: this.session.settings,
signal,
localProtocolOptions: this.session.localProtocolOptions,
skills: this.session.skills,
});
if (localFile) {
readPath = localFile.path;
// Preserve a local:// selector separately so a sibling literal file
// cannot shadow the URL's selector semantics during filesystem routing.
promotedSelector = internalTarget.sel;
} else {
if (parsed.kind === "image") throw new ToolError(imageSelectorMessage);
return this.#handleInternalUrl(internalTarget.path, parsed, signal);
}View on GitHub (pinned to 9690622007)
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'.
Example fix
// before
read("agent://diagram:img")
// after
read("local:///tmp/diagram.svg:img") Defensive patterns
Strategy: validation
Validate before calling
if (sel === 'img' && !url.startsWith('local://')) throw new Error(':img requires a local:// .svg/.svgz target'); Type guard
function canUseImgSelector(url) { return url.startsWith('local://') && /\.svgz?$/i.test(url.split(':img')[0]); } Try / catch
try { return await read(url) } catch (e) { if (String(e.message).includes(':img')) { return await read(url.replace(':img','')); } throw e; } Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- Invalid selector ':${internalTarget.sel}' on '${internalTarg
- Multi-range line selectors are not supported for directory l
- Cannot combine query extraction with line selectors
- path entry "${entry}" has an invalid selector ":${internalSp
- path entry "${entry}" — only line-range selectors like ":50-
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/1c1b8d36ab8b7eba.
Report an issue: GitHub.