{"record":{"id":"758d35c0ae80f660","repo":"can1357/oh-my-pi","slug":"cannot-combine-query-extraction-with-line-selector","errorCode":null,"errorMessage":"Cannot combine query extraction with line selectors","messagePattern":"Cannot combine query extraction with line selectors","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/read.ts","lineNumber":2215,"sourceCode":"\t\t}\n\t\tif (scheme === \"artifact\") {\n\t\t\treturn this.#readArtifactFile(urlMeta, parsedSel, signal);\n\t\t}\n\n\t\t// local:// files are real on-disk paths. Detect image files and emit a\n\t\t// decoded image block before the text-only resource contract UTF-8\n\t\t// decodes the binary into mojibake. The fast path returns null for\n\t\t// non-images, directories, listings, or any resolution failure, so the\n\t\t// text path below reproduces the router's not-found / symlink-escape\n\t\t// behavior unchanged.\n\t\tif (scheme === \"local\") {\n\t\t\tconst imageResult = await this.#tryReadLocalImage(urlMeta, signal);\n\t\t\tif (imageResult) return imageResult;\n\t\t}\n\n\t\t// Reject line selectors when query extraction is used\n\t\tif (hasExtraction && parsedSel.kind !== \"none\" && parsedSel.kind !== \"raw\") {\n\t\t\tthrow new ToolError(\"Cannot combine query extraction with line selectors\");\n\t\t}\n\n\t\t// Resolve the internal URL\n\t\tconst resource = await internalRouter.resolve(url, {\n\t\t\tcwd: this.session.cwd,\n\t\t\tsettings: this.session.settings,\n\t\t\tsignal,\n\t\t\tsessionFile: this.session.getSessionFile() ?? undefined,\n\t\t\tlocalProtocolOptions: this.session.localProtocolOptions,\n\t\t\tskills: this.session.skills,\n\t\t\txd: {\n\t\t\t\tread: async name => {\n\t\t\t\t\tif (name === REPORT_ISSUE_DEVICE_NAME) return reportIssueDeviceUsage();\n\t\t\t\t\tif (name && isResolutionDeviceName(name)) return resolutionDeviceUsage(name);\n\t\t\t\t\tconst xdev = this.session.xdev;\n\t\t\t\t\tif (!xdev) throw new ToolError(\"xd:// is not mounted in this session.\");\n\t\t\t\t\treturn name === null ? xdevListing(xdev) : xdevDocs(xdev, name);\n\t\t\t\t},","sourceCodeStart":2197,"sourceCodeEnd":2233,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/read.ts#L2197-L2233","documentation":"Query extraction (a ?q= parameter or pathname extraction on agent:// URLs) and line selectors (:N, ranges) are mutually exclusive ways to narrow content. ReadTool throws if both are present, since it cannot apply a line slice to an extraction result.","triggerScenarios":"read('agent://resource?q=foo:10-20') or any URL where hasExtraction is true and parsedSel.kind is a line range (not 'none' or 'raw').","commonSituations":"Appending a standard line-range selector out of habit onto a query-extraction URL; combining two narrowing features the agent generated independently.","solutions":["Remove the line selector and rely on the query extraction.","Remove the ?q= extraction and use only the line selector on the full resource.","Use :raw with extraction if raw bytes of the extracted result are acceptable per the allowed kinds."],"exampleFix":"// before\nread(\"agent://api/list?q=users:5-10\")\n// after\nread(\"agent://api/list?q=users\")","handlingStrategy":"validation","validationCode":"if (url.includes('?q=') && /:\\d+(-\\d+|\\+\\d+|-)?(,|$)/.test(url)) throw new Error('Drop either query extraction or the line selector');","typeGuard":"function hasConflictingFeatures(url) { const [u, sel] = splitInternalUrlSel(url); return /[?&]q=/.test(u) && sel !== undefined && !['raw','none'].includes(sel); }","tryCatchPattern":"try { return await read(url) } catch (e) { if (String(e.message).includes('query extraction')) { return await read(url.replace(/:\\d.*$/, '')); } throw e; }","preventionTips":["Never append line-range selectors to URLs carrying ?q= extraction","Choose one narrowing mechanism per read call","Centralize URL+selector assembly so the constraint is enforced in one place"],"tags":["read-tool","selector-syntax","query-extraction"],"backgroundTag":"unsupported-selector-combination","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}