Repository navigation
fix(agents): web_fetch 403/404/429 no longer page Sentry as unhandled exceptions - #282
Conversation
…as unhandled exceptions A blocked/missing/rate-limited external web_fetch target threw a plain Error wrapped in the untrusted-content SECURITY NOTICE banner, which sentry-monitor's after_tool_call hook reported as a full exception — ~20/day on the fleet, polluting reliability telemetry for routine external outcomes. - web-fetch.ts: non-OK responses now throw a WebFetchStatusError carrying a stable `http_<status>` code instead of a free-form bannered message, so after_tool_call consumers can classify it without sniffing error text. - 429 now retries (bounded, backoff, honors Retry-After) via the existing retryAsync helper before giving up; 403/404 are not retried. - captures.ts: web_fetch + upstream + http_403/404/429 downgrades to a non-paging Sentry warning, scoped narrowly so web_fetch's own network failures and every other tool's upstream failures still page as before. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 4 files
Linked issue analysis
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Treat 403, 404, and 429 as non-error Sentry events | captures.ts downgrades only web_fetch upstream failures with these codes to warning-level messages. |
| ✅ | Return a clean, structured failure for the agent | web-fetch.ts throws a bannerless status error with a stable http_<status> code, and tests verify its message. |
| ✅ | Retry HTTP 429 responses with backoff | web-fetch.ts retries 429 responses with bounded backoff, honors Retry-After, and tests cover recovery and exhaustion. |
| ✅ | Keep the security notice out of Sentry errors | The HTTP error includes only its status, and tests confirm it contains no security banner or untrusted-content marker. |
| Verify the reported error volume drops to zero | Tests confirm these events become warnings, but the diff provides no post-deployment Sentry volume verification. |
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
cubic review on #282 flagged that a Retry-After longer than the 8s max delay was being silently clamped and retried early anyway, instead of respecting the server's cooldown. Skip the retry and surface the 429 immediately when retryAfterMs exceeds WEB_FETCH_429_MAX_DELAY_MS. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
… audit security-fast (pnpm-audit-prod --audit-level=high) was failing on this PR with 6 pre-existing high/critical advisories, unrelated to the ENG-21225 change itself but present on boon regardless. Two are safe in-range patch bumps: - proxy-addr 2.0.7 -> 2.0.8 (GHSA-jqcg-44mw-7w3h, IP spoofing via IPv4-mapped IPv6 trust subnet) - source-map-js 1.2.1 -> 1.2.2 (GHSA-68fv-2mgg-jv7q, event-loop DoS via indexed source-map section offsets) Verified: tsgo:core, tsgo:extensions clean; full oxlint clean; 708 channel tests (express-dependent) and 183 bundled-package tests pass. The remaining 4 findings are all simple-git, whose fix requires a 3.x->4.x major bump. node-llama-cpp (the only consumer, via its optional llama-cpp-provider dependency) declares `simple-git: "^3.33.0"` and even its latest release (3.22.1) still does -- upstream hasn't migrated to simple-git 4.x at all, so there's no compatible target to bump to yet. Forcing the override would go beyond what any version of the dependent has been tested against, with no local test coverage for this optional, native-binding-adjacent feature to catch a regression. Left as a known, pre-existing, tracked risk rather than force a major bump blind -- matches this file's own stated convention ("conservative in-range targets where possible, no major bumps"). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Turn on auto-fix | Re-trigger cubic
The previous commit bumped proxy-addr 2.0.7 -> 2.0.8 in pnpm-lock.yaml but
left npm-shrinkwrap.json stale, which checks-node-core-tooling's
package-manager-config.test.ts ("keeps npm shrinkwrap package versions
inside the pnpm lock graph") correctly caught as a real drift -- not the
pre-existing opentelemetry generator flake that check-shrinkwrap already
tolerates.
Patched by hand (version/resolved/integrity) in the root shrinkwrap and
the three extensions that bundle express (acpx, msteams, slack) rather
than regenerating via scripts/generate-npm-shrinkwrap.mjs, which hits that
unrelated pre-existing @opentelemetry/resources / @opentelemetry/sdk-trace-base
nondeterminism (npm resolves a newer published version than pnpm's locked
2.11.0 for an unrelated transitive range) before it ever reaches proxy-addr.
Verified the real patch (dependencies/engines unchanged between 2.0.7 and
2.0.8) against the npm registry metadata directly. source-map-js never
appears in any committed shrinkwrap (pure dev/test-tooling transitive dep),
so it needed no corresponding edit here.
Verified: package-manager-config.test.ts passes locally (12/12); tsgo:core,
tsgo:extensions, tsgo:test clean; full oxlint clean; 708 channel tests +
183 bundled tests still pass.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
… findings Forces the remaining 4 advisories (GHSA-v5rq-49vh-5v5c, GHSA-x6jw-m9v5-85vh, GHSA-g4wm-2vf7-vfgr, GHSA-858h-whjf-mvg5 -- unsafe-operations guard bypasses allowing command execution) via a pnpm-workspace.yaml override, despite the major 3.x -> 4.x bump this requires. node-llama-cpp (the only consumer, via the optional llama-cpp-provider extension) declares simple-git ^3.33.0 and even its latest release still does, so this goes beyond what any version of the dependent has been tested against on paper. Verified it's safe in practice before forcing it: - node-llama-cpp only imports the long-stable `simpleGit()` factory and calls `.clone()`/`.removeRemote()` on the result -- core API untouched across the major bump, and it never touches the deprecated `simple-git/promise` subpath that 4.x actually removed. - Both the CJS and ESM entry points still resolve and expose the same shape (smoke-tested directly: `require("simple-git")` and `import("simple-git")` both return a working `simpleGit` factory). - extensions/llama-cpp's own test suite passes unchanged (11/11). - `@simple-git/argv-parser` (simple-git's own sub-package, the oddly-named "@simple-git/argv-parser" advisory from the original scan) resolves to 2.0.1, the actual fixed version. extensions/llama-cpp/npm-shrinkwrap.json regenerated via `generate-npm-shrinkwrap.mjs --package-dir extensions/llama-cpp` -- this extension has no @sentry/node dependency, so it isn't affected by the unrelated opentelemetry generator nondeterminism that blocked a full `--all` regeneration. `pnpm-audit-prod.mjs --audit-level=high` now reports zero findings. Verified: tsgo:core, tsgo:extensions, tsgo:test clean; full oxlint clean; the shrinkwrap-consistency test, llama-cpp's test suite, 708 channel tests, and 183 bundled-package tests all still pass. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved ✅ (0 issues, 0 suggestions)
PR: #282 — fix(agents): web_fetch 403/404/429 no longer page Sentry as unhandled exceptions
Author: @william-antoline-boon
Commit: 1994167e2d8d04fb55e000103e5733d109369a5a
✅ Looks Good
- Clean error classification: Replacing untrusted body extraction and security banners on HTTP error responses with
WebFetchStatusError(http_<status>) provides clean, structured failure signaling forafter_tool_callhooks. - Narrow downgrade scope: Sentry monitor specifically downgrades
web_fetch+upstream+http_403/http_404/http_429to warning level, leaving web_fetch's own network/SSRF failures and other tools' upstream errors as full exceptions. - Robust 429 retry handling: Rate limits are retried with bounded backoff and jitter, respecting
Retry-Afterwhile properly refusing to retry early if cooldown exceeds the 8s ceiling. SSRF guard connection holds are immediately released on 429 to prevent socket leaks. - Comprehensive test coverage: Tests verify status codes, absence of security banner wrappers, 429 recovery/exhaustion/Retry-After handling, and exact downgrade isolation in
captures.test.ts. - Security & dependency hygiene: Cleanly resolved advisory findings via
proxy-addr(2.0.8),source-map-js(1.2.2), andsimple-git(4.0.2), keeping workspace overrides, pnpm lockfile, and npm shrinkwraps in sync. - All CI checks green: All required quality, security, and typecheck gates passed cleanly.
Reviewed by Hermes Agent
🧪 Live e2e verification (real network, not mocks)The unit suite covers this fix against a mocked
¹ includes a one-time 7.4s plugin cold-start on first run, not part of the fetch itself. What this proves:
Counting real requests took a detour worth flagging for reviewers: wrapping Raw outputEverything the live run can't control (recovery after a transient 429, honoring
Also landed on this branch: All 106 CI checks are green on the current head. |
🧑💻 Manual e2e — real model, real agent turn (addendum)Fair callout on the earlier comment: the live-network pass above proves the tool is correct against a real server, but it never went through a real model deciding to call it. Closing that gap here. Built this branch's CLI from source (
What this proves that the live-network pass alone couldn't:
Full write-up (all three layers — manual e2e, live network with exact request counts, mocked suite, dependency audit): https://claude.ai/code/artifact/176ee9de-40c8-4dc1-b4a4-9392d2733a06 |
…npm-lock.yaml Two independent merges (upstream v2026.6.35 sync + boon PR #282/#284) each added their own simple-git/proxy-addr/source-map-js CVE overrides without textually overlapping, so git's line-based merge kept all copies instead of flagging a conflict. The resulting duplicate YAML mapping keys broke CI's strict-mode lockfile parse at the "Resolve pnpm store path" step. Consolidated to one override per package (same resolved versions throughout, so no shrinkwrap changes). Co-Authored-By: Claude Sonnet 5 <[email protected]>
- short-term-promotion.ts: type the realpath-resolution catch callback as `: unknown` per repo oxlint convention (use-unknown-in-catch-callback-variable). - web-tools.fetch.test.ts: drop 10 `as Promise<Response>` casts left over from PR #282's MockResponse-based mocks; errorResponse() now returns a real Response directly after the merge conflict resolution, so the casts are unnecessary (no-unnecessary-type-assertion). Reformatted with oxfmt. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Cut the fork release that ships the six commits on boon since v2026.6.34-boon.6: - #286: decouple Rastermill's image decode and output pixel budgets so a source image above 25 megapixels downscales instead of being rejected outright; plus HEIC/data-URL pixel-guard and error-detail fixes. - #283 (ENG-21233): classify a caller's external timeout abort as a clean interruption instead of leaking DOMException's TimeoutError code as "Turn budget exceeded | 23" on agent_end. - #284 (ENG-21229): re-derive the memory-flush write guard's allowed path at execute time so a flush crossing midnight no longer rejects the correct current-date path. - #282 (ENG-21225): web_fetch 403/404/429 no longer page Sentry as unhandled exceptions; 429 now retries with bounded backoff honoring Retry-After. - #285: remove a duplicate simple-git/proxy-addr/source-map-js overrides block that crashed pnpm store path on every PR against boon. - #275: bump music-metadata 11.12.3 -> 11.16.0. Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version/peer floor in every extension npm-shrinkwrap.json via pnpm release:prep. The npm-shrinkwrap generator can't regenerate cleanly on this fork (pre-existing, unrelated @sentry/node nested @opentelemetry/resources / sdk-trace-base registry-resolution drift, verified present on unmodified origin boon); hand-patched the affected shrinkwrap version/peer-floor fields instead, verified against test/package-manager-config.test.ts (12/12 passing). Add the 2026.6.34-boon.7 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No config schema, plugin-SDK surface, or plugin source/dependency change in slack/msteams/diagnostics-prometheus; this is a gateway-only roll. Co-authored-by: Claude Sonnet 5 <[email protected]>
…still building (#288) * fix(memory): memory search no longer pages Sentry while the index is still building A "missing" index identity (no catalog built yet -- the ordinary state for the first moments of a new session/workspace) was treated the same as a "mismatched" one (a real, operator-actionable config drift): resolvePausedMemoryIndexIdentityReason paused memory_search for both, returning a disabled/error result with a misleading "built with a different embedding provider" explanation. That bare error field was enough for the host's generic tool-result classifier to flag it as a real exception, with no sentry-monitor carve-out catching it (the same noisy-tool-result class already fixed for web_fetch 403/404/429 in #282) -- paging OPENCLAW-FLEET-X4 on every cold-start race, 166 events across 7 customer hosts over 44 days. Narrow resolvePausedMemoryIndexIdentityReason to only pause on "mismatched". "missing" now falls through to the normal search flow, where it also gets a real chance at tools.ts's own forced-retry-sync block (previously unreachable for this case, since the early return happened first). Fixes: ENG-21227 / OPENCLAW-FLEET-X4 Co-Authored-By: Claude Sonnet 5 <[email protected]> * address review: trim ticket/incident references from source comment Per cubic-dev-ai review feedback: keep the comment focused on the missing-vs-mismatched behavior and its false-unavailable-result consequence, not ticket/incident lore. --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
Related: ENG-21225 (Linear) / Sentry OPENCLAW-FLEET-112
What Problem This Solves
Resolves a problem where a routine external web_fetch failure — a target
site returning HTTP 403 Forbidden, 404 Not Found, or 429 Too Many Requests —
was reported to Sentry as a full, unhandled-exception-level event, complete
with the untrusted-content SECURITY NOTICE banner baked into the issue
title/message. This fired ~20 times/day on the fleet (customer
guido),polluting reliability telemetry for outcomes that are the external site's
call, not a host defect, and burying real agent failures behind noise.
Why This Change Was Made
web-fetch.tsthrew a plainErrorfor any non-OK HTTP response, with nostructured signal distinguishing "external site said no" from a genuine host
defect — so the host's existing
after_tool_callerror classification(
denied/invalid-input/timeout/internal/exit-error/upstream)could only ever bucket it as
upstream, and sentry-monitor'sbuildAfterToolCallCapturereports everyupstreamfailure as a fullexception today.
The fix tags the thrown error with a stable
http_<status>code (sosentry-monitorcan classify it without sniffing error text — the host'sown stated design principle for this hook), downgrades specifically
web_fetch+upstream+http_403/http_404/http_429to a non-pagingSentry warning (kept visible, not dropped — "is a site blocking us a lot" is
still useful signal), and stops borrowing the untrusted-content
security-banner wrapper for the error path (that wrapper is for real fetched
page content, not a one-line HTTP status). 429 additionally gets a bounded
retry with backoff (honoring
Retry-Afterwhen present) via the existingretryAsynchelper, since a rate limit is often transient; 403/404 are notretried since the response won't change.
The suppression is scoped narrowly — tool name AND errorKind AND errorCode
must all match — so it cannot broaden to hide web_fetch's own
network/SSRF/extraction failures, or any other tool's genuine
upstreamdependency failures, which still report as full exceptions exactly as
before.
User Impact
events; fleet reliability dashboards no longer count "a site returned
403" as a system error.
as a clear tool failure (
Web fetch failed: HTTP 403 Forbidden), justwithout the multi-paragraph security banner bolted onto a one-line status.
A 429 now self-heals via retry in many cases instead of failing
immediately.
Evidence
src/agents/tools/web-tools.fetch.test.ts: new coverage for the cleanbannerless message +
http_<status>code on 403/404/500, the 429retry-with-backoff (succeeds, honors
Retry-After, exhausts and stillthrows
http_429), and confirms 403 is never retried. All 29 tests inthis file pass.
extensions/sentry-monitor/src/captures.test.ts: new coverage provingthe downgrade fires only for the exact (tool, kind, code) tuple, and that
web_fetch's own non-HTTP upstream failures, a different tool's
http_403, and web_fetch upstream failures with an unrelated errorCodeall still capture as full exceptions. All 64 tests in this file pass.
pnpm tsgo:core,pnpm tsgo:extensions,pnpm tsgo:testall pass clean.npx oxlinton the four touched files passes clean.Co-Authored-By: Claude Sonnet 5 [email protected]
https://claude.ai/code/session_01SwbaRBNg1tXBa2GXP1ztVE
Summary by cubic
Stops routine external
web_fetchfailures (HTTP 403/404/429) from paging Sentry as unhandled exceptions, so fleet reliability telemetry no longer counts blocked, missing, or rate-limited target sites as system errors.WebFetchStatusErrorcarrying a stablehttp_<status>code instead of a free-form message wrapped in the untrusted-content SECURITY NOTICE banner.Retry-Afterunless it exceeds the 8s max delay, in which case the 429 is surfaced immediately to respect the server's cooldown); 403/404 are never retried since the outcome won't change.sentry-monitordowngradesweb_fetch+upstream+http_403/http_404/http_429to a non-paging warning, scoped narrowly soweb_fetch's own network/extraction failures and other tools' upstream failures still report as full exceptions.Dependencies
proxy-addrto 2.0.8 andsource-map-jsto 1.2.2, and forcessimple-gitto 4.0.2, clearing all high-severity advisory findings in the security-fast audit.proxy-addrfor the root and the three express-bundling extensions,simple-gitforllama-cpp.source-map-jsneeds no shrinkwrap edit since it's a dev-only transitive. Thesimple-git4.x major bump is safe in practice:node-llama-cpp(the only consumer) only uses the stablesimpleGit()factory's.clone()/.removeRemote(), and its test suite passes unchanged.Written for commit 1994167. Summary will update on new commits.