You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebFetch returns raw XHTML in Markdown and text modes #63888
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the precise report. I reproduced this on opencode v2.2.7, and it also happens on the latest dev (f0089856).
What I ran: a local server returned the page from your report, once as application/xhtml+xml; charset=utf-8 and once as text/html; charset=utf-8. I let the real built-in webfetch tool fetch it through opencode run. A local mock stood in for the model; its only job was to request the fetch. Results:
XHTML, format: "markdown": the raw <html xmlns="http://www.w3.org/1999/xhtml"><body><h1>Guide</h1></body></html>
XHTML, format: "text": the same raw markup
text/html, markdown: # Guide
text/html, text: Guide
The cause looks like the one you found: convert() in packages/core/src/tool/plugin/webfetch.ts only converts when the header contains text/html. The script below reproduces it.
so application/xhtml+xml fell straight through. It now matches XHTML explicitly through mimeFrom, which also keeps ignoring the charset parameter.
Test sits next to the existing HTML case in packages/core/test/tool-webfetch.test.ts and drives the real tool with your synthetic response: # Guide for markdown, Guide for text. Fails on dev (raw markup comes back), passes with the change; the file is 92 pass and typecheck-clean.
Branch webfetch-xhtml. PR creation is refused for this account at the moment (FORBIDDEN on CreatePullRequest, masked as 404), so it waits as a branch with the body written.
Thanks for the report! This looks like the same bug as #49322, so I'm closing this one to keep the discussion in one place. If yours turns out to be different, leave a comment and we'll reopen it.
Activity
opencodejr commentedon Nov 14, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the precise report. I reproduced this on
opencode v2.2.7, and it also happens on the latestdev(f0089856).What I ran: a local server returned the page from your report, once as
application/xhtml+xml; charset=utf-8and once astext/html; charset=utf-8. I let the real built-inwebfetchtool fetch it throughopencode run. A local mock stood in for the model; its only job was to request the fetch. Results:format: "markdown": the raw<html xmlns="http://www.w3.org/1999/xhtml"><body><h1>Guide</h1></body></html>format: "text": the same raw markuptext/html, markdown:# Guidetext/html, text:GuideThe cause looks like the one you found:
convert()inpackages/core/src/tool/plugin/webfetch.tsonly converts when the header containstext/html. The script below reproduces it.Related:
Text/HTMLReproduction script (repro.sh)
Run it:
bash repro.shGuembri01 commentedon Nov 25, 2026
Took this. The decision was a single substring test:
so
application/xhtml+xmlfell straight through. It now matches XHTML explicitly throughmimeFrom, which also keeps ignoring thecharsetparameter.Test sits next to the existing HTML case in
packages/core/test/tool-webfetch.test.tsand drives the real tool with your synthetic response:# Guidefor markdown,Guidefor text. Fails ondev(raw markup comes back), passes with the change; the file is 92 pass and typecheck-clean.Branch
webfetch-xhtml. PR creation is refused for this account at the moment (FORBIDDENonCreatePullRequest, masked as 404), so it waits as a branch with the body written.fix(core): convert XHTML in webfetch markdown and text modes
fix(core): convert XHTML in webfetch markdown and text modes
Guembri01 commentedon Nov 27, 2026
PR opened: #66871. Rebased on current dev after this comment; the test file now has 90 pass, 0 fail (upstream removed one test in the same area).
fix(core): convert XHTML and mixed-case HTML in webfetch
fix(core): convert XHTML and mixed-case HTML in webfetch
fix(core): convert XHTML and mixed-case HTML in webfetch
neriousy commentedon Dec 2, 2026
Thanks for the report! This looks like the same bug as #49322, so I'm closing this one to keep the discussion in one place. If yours turns out to be different, leave a comment and we'll reopen it.