Repository navigation
fix(web-fetch): balanced link URLs leak into extracted text - #180605
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR reuses the balanced Markdown link parser and preserves HTML anchor labels directly during text extraction. Example: Fetch Markdown containing Cassini with extractMode=text.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it fixes a current extraction defect with a focused change, and no introduced correctness or security defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe web_fetch extraction layer converts HTTP response bodies into model-facing Markdown or text, sharing link parsing with session previews. flowchart TD
A[HTTP response] --> B[Markdown extraction]
A --> C[Basic HTML extraction]
C --> D[Anchor labels]
B --> E[Balanced link parser]
D --> E
E --> F[Text tool result]
Technical reviewBest possible solution: Keep the shared balanced parser and direct HTML label rendering while preserving preview defaults, image omission, and fenced-code literals. Do we have a high-confidence way to reproduce the issue? Current-main regexes demonstrably stop at the first closing parenthesis; the supplied failing-base result matches that mechanism, but this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair using existing owners: reuse the maintained parser and remove the lossy HTML destination round trip. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ab7631a25601. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +14, Tests +22, Docs +1. Total +37 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 24, 2026, 6:54 PM ET / 22:54 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#180605) * fix(web-fetch): consume complete balanced link destinations * fix(web-fetch): serialize HTML anchor parentheses for text parsing * fix(web-fetch): retain literal HTML anchor text without a Markdown round trip * docs: clarify web fetch link text extraction --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(web-fetch): consume complete balanced link destinations * fix(web-fetch): serialize HTML anchor parentheses for text parsing * fix(web-fetch): retain literal HTML anchor text without a Markdown round trip * docs: clarify web fetch link text extraction --------- Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 9c39447) Co-authored-by: RomneyDa <[email protected]> Narrow companion adaptation; source author date: 2026-10-16T12:09:42+08:00 (cherry picked from commit 42ff52b) Co-authored-by: Ben.Li <[email protected]> Narrow companion adaptation; source author date: 2026-10-24T21:08:45-04:00 (cherry picked from commit ad2172d) Co-authored-by: AmelioMansour <[email protected]> Narrow companion adaptation; source author date: 2026-10-24T22:22:35-07:00 (cherry picked from commit a36d048) Co-authored-by: Peter Steinberger <[email protected]> Narrow companion adaptation; source author date: 2026-10-26T20:14:49+08:00 (cherry picked from commit 7639f53) Co-authored-by: yy19971996 <[email protected]> (cherry picked from commit e5fb9dfdf6e68f5a8209056f68352413f1a237c7)
… [baseline validation follow-up] * fix(web-fetch): consume complete balanced link destinations * fix(web-fetch): serialize HTML anchor parentheses for text parsing * fix(web-fetch): retain literal HTML anchor text without a Markdown round trip * docs: clarify web fetch link text extraction --------- Co-authored-by: Peter Steinberger <[email protected]> Complete the source-equivalent baseline adaptation and checked-in regressions; normalize with the checkout formatter. (cherry picked from commit 9c39447) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 81d1a6a44ab65b53de3bf348393b855a7d18d14c)
What Problem This Solves
Fixes: text-mode
web_fetchresults leak URL suffixes when Markdown link destinations contain nested parentheses.User Impact
[Cassini](https://example.com/a_(b(c)))becomesCassini, without stray closing parentheses. Images stay omitted from web text, while one-line previews keep their existing image labels. HTML anchor labels remain readable even with spaces or unmatched parentheses in the destination. No configuration or migration changes are required.Why This Change Was Made
Replace the two first-closing-parenthesis regexes with the existing balanced-link parser. The shared parser retains its preview default and supports omitting images for web extraction. Basic HTML text extraction keeps anchor labels directly instead of serializing arbitrary HTML URLs as Markdown and parsing them again. Thanks @AmelioMansour for the fix and its regression cases.
Evidence
Read Cassini)) and .png)., then passes with this repair. The full extraction, normalizer, and Readability suites pass: 46 + 23 + 7 tests. Vitest durations were 4.04s, 7.70s, and 11.16s; combined wrapper wall time was 34.96s on a busy host.createWebFetchTool().executein isolated process state reproduced leaked Markdown/HTML suffixes and malformed-Markdown rewriting on base. All seven head fixtures pass: balanced links, unmatched HTML parentheses, a space-bearing HTML URL, a trailing label backslash, unchanged HTML Markdown output, and malformed Markdown preservation. The synthetic server was stopped. A full Gateway/model session was not run; the HTTP tool invocation exercises the changed extraction boundary.git diff --checkpass. Broad proof is provided by exact-head PR CI.Current CI limitation
Exact-head run 40140057766 finished red in two Gateway recovery cases:
gateway-widget-restart.e2e.test.ts(widget revision stayed at 1) andgateway-restored-requester-settle.e2e.test.ts(three restored wakes instead of two). Their classification is unknown because the scheduled-main run uses different shard coverage; no matching main failure has been established. The extraction regressions and targeted checks above pass. These failures have not been rerun merely to obtain green CI.A bounded local baseline attempt on main
085076cc8f76c05b58166f85d792d851ac6c6d68usedTMPDIR=/private/tmp/oc-ct-webfetch OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs test/gateway-widget-restart.e2e.test.ts test/gateway-restored-requester-settle.e2e.test.ts --maxWorkers=1. Runtime preparation took 23m19s and worker preparation another 213.5s; the attempt was stopped after 30 minutes without a test verdict. The completed build was not interrupted. This establishes an environment/proof limitation, not an inherited-failure classification. No CI rerun was requested.