Skip to content

fix(agents): redact reflected credentials from provider error detail and reason phrase - #120200

Merged
steipete merged 2 commits into
openclaw:mainfrom
zenglingbiao:fix/web-search-redact-error-body
Aug 27, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
zenglingbiao:fix/web-search-redact-error-body

Conversation

@zenglingbiao

@zenglingbiao zenglingbiao commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where web-search users could expose their request credential in an error when a provider or proxy reflected it in the response body or HTTP reason phrase. Short keys and credentials cut by the diagnostic byte limit also need protection.

Related: #117304, #119536.

Why This Change Was Made

The maintainer rewrite keeps this policy at the authenticated request owner. The shared web helper now passes the actual outgoing headers to the existing request-aware provider-error redactor. Perplexity's native Search and Sonar/OpenRouter paths carry the same context. General tool-payload redaction is unchanged, so ordinary text such as Bearer tokens remains intact.

Request construction now uses Headers.set for owned fields: differently cased caller headers cannot combine two Authorization values. Error-body cancellation retains the caller's original reason. The existing two-argument SDK error helper remains usable; request context is an optional third argument.

Removed copied xAI HTTP mocks, duplicate parser-only checks, and test-only parser exports. Retained tests now exercise the shared HTTP owner and the production citation parser caller.

The first hosted CI run exposed an existing process-supervisor race: a detached compiler could become ready before its supervisor installed signal handlers. An early SIGTERM could then orphan the compiler. The shared managed-process owner now installs handlers before spawning, retains them for concurrent commands, and removes idle handlers after either synchronous or asynchronous spawn failure. The regression exercises the real process boundary; no timeout was increased.

User Impact

Perplexity, Tavily, and the xAI web/X-search/code-execution family retain provider labels, HTTP status, and bounded diagnostics while removing recognized reflected credentials. Successful responses and ordinary chat/tool prose are unchanged. No new configuration, dependencies, schema, or persistent-state design.

Thanks @zenglingbiao for the report, initial fix, and reflection reproductions; contributor co-authorship is preserved.

Evidence

Rewritten head: b66c19aee848087f612d6745f3ec8b2dea015217. Exact-head CI passed at 22:29:17 UTC on August 27, 2026. Native validation, prepare and merge completed successfully; merged as 213804d77046ce5d0e3cae84fa0fc4742625f064 at 23:17:31 UTC. All 15 landed file blobs independently match the reviewed head, and the merge is an ancestor of freshly fetched main. The previous run failed the compiler-reaping regression described below, not the web-provider tests.

  • On the unchanged main baseline, real loopback HTTP responses reproduced four credential leaks and the post-header cancellation bug: 5 failed / 3 passed. These tests inject routing only; they consume actual HTTP response bodies and are not authenticated provider proof.
  • Both Perplexity transport regressions failed before passing request context: 2 failed.
  • A second HTTP regression reproduced combined mixed-case Authorization headers: 5 failed, then passed after canonical request construction.
  • Final focused and sibling suites: 230 passed across the shared HTTP/error/guard helpers, Perplexity, Tavily, xAI web search, X search, code execution, and citation parsing.
  • Final isolated Codex autoreview of the assembled 15-file patch: no actionable P0 findings. A separate whole-owner review identified the mixed-case header defect above; it is fixed and regression-tested.
  • Full local build passed, including public SDK export/declaration checks and Control UI build checks; no ineffective dynamic-import warning.
  • Final authenticated live provider calls succeeded for Perplexity native Search and Sonar. Real invalid-key requests to both Perplexity transports and Tavily safely reported 401. Tavily authenticated success is not claimed.
  • Built-Gateway /tools/invoke proof passed with real Perplexity: valid auth returned HTTP 200 with a normalized search result; invalid auth returned the documented sanitized HTTP 500 while recording the provider's 401 diagnostic without the synthetic credential. Both isolated instances and their temporary state were removed.
  • The full changed-file gate passed, including all production/test typechecks, typed lint, dead-export checks, SDK boundaries, and runtime import-cycle checks. One earlier attempt caught a missing unknown annotation in a test catch callback; it is fixed and all eight shared-owner tests passed again. Application production bytes are unchanged from the successful build/live proof. Exact-head hosted CI remains required before landing.
  • CI repair: a deterministic real-process probe observed the pre-fix wrapper exit on SIGTERM with zero registered listeners and a live compiler. The repaired supervisor registered its listener before spawn and exited 143 after reaping the compiler. The tracked regression also failed with the old ordering restored. All 91 tests across four tooling/helper files, the additional local changed-file gate, and a fresh isolated P0 review passed. All twelve web-fix file blobs are unchanged from the preceding verified head; the added tooling repair is separately covered.
  • The final-head pnpm openclaw --help invocation completed successfully after the normal git-head-triggered rebuild. ClawSweeper's separate build-plus-help probe timed out before its build completed; that timeout is not reported as a successful probe. The completed local build, help invocation, and authenticated provider/Gateway flows above provide the actual evidence.

Commands run:

node scripts/run-vitest.mjs src/agents/tools/web-search-provider-common.test.ts src/agents/tools/web-shared.test.ts src/agents/tools/web-guarded-fetch.test.ts src/agents/provider-http-errors.test.ts extensions/perplexity/src/perplexity-web-search-provider.test.ts extensions/tavily/src/tavily-client.test.ts extensions/tavily/src/tavily-tools.test.ts extensions/xai/web-search.test.ts extensions/xai/src/responses-tool-shared.test.ts extensions/xai/x-search.test.ts extensions/xai/code-execution.test.ts
node scripts/run-vitest.mjs test/scripts/managed-child-process.test.ts test/scripts/run-tsgo.test.ts test/scripts/direct-run-entrypoints.test.ts test/helpers/process-wait.test.ts
git diff --name-only -z | xargs -0 env -u OPENCLAW_TESTBOX node scripts/check-changed.mjs --
env -u OPENCLAW_TESTBOX pnpm build
env -u OPENCLAW_TESTBOX pnpm docs:list
env -u OPENCLAW_TESTBOX pnpm openclaw --help

Judged LOC: application production −18, tooling production −74 (combined −92), tests +55, docs +4; total −33. No generated, lockfile, or snapshot churn.

Latest ClawSweeper review at 21:40 UTC reports no blocking correctness findings and retains exact-head hosted checks as the remaining gate. Those checks are now green. Earlier rank-up moves are addressed: request-local short-credential redaction, preserved global ordinary-prose behavior, current-main owner comparison, and real HTTP proof. A fresh review was requested after the additional CI process-owner repair.

Provenance: the raw-error helper was already present in 3de973ffff2e6803b85906ba94ed8ace77f3618d, authored and committed by @Takhoffman on March 18, 2026. This establishes an earlier occurrence, not the first introduction; no associated PR was returned. The local shallow boundary cannot establish the header-construction defect's original author.

Named follow-up: Exa and Parallel have separately owned x-api-key error paths that do not carry request-aware redaction context. This PR does not claim to cover those paths or every possible encoding of sensitive response data.

Separate process-owner follow-up: scripts/run-with-env.mts also installs handlers after spawning. That distinct path has not been reproduced here and is not claimed fixed by this PR.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 7, 2026
@zenglingbiao
zenglingbiao force-pushed the fix/web-search-redact-error-body branch from e42faf6 to 982ec71 Compare August 7, 2026 10:20
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:40 PM ET / 21:40 UTC.

ClawSweeper review

What this changes

This PR redacts credentials reflected in Perplexity, Tavily, and xAI web-search HTTP error bodies or reason phrases while retaining bounded non-sensitive diagnostics.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The rewritten head repairs a current-main credential-reflection path at the authenticated request owner, keeps the prior global-prose regression out of scope, and has sufficient real-behavior evidence; no blocking correctness finding remains. Exact-head hosted checks were still running in the supplied state.

Priority: P1
Reviewed head: c853f369b47ea95feb8e410cc6a29ba2d20dc0bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative repair with credible transport and gateway proof; hosted exact-head checks remain the normal landing gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body records before/after real loopback transport runs plus authenticated Perplexity and built-Gateway success/error evidence; redact private diagnostics if additional proof is posted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records before/after real loopback transport runs plus authenticated Perplexity and built-Gateway success/error evidence; redact private diagnostics if additional proof is posted.
Evidence reviewed 6 items Current-main failure path: Fetched main constructs authenticated headers and interpolates the bounded response body or reason phrase directly into the thrown error, so a reflected credential remains observable before this PR is merged.
Introduced shared repair: The PR makes one canonical Headers instance for the actual request, passes it to the error owner, preserves cancellation, and invokes the request-aware redactor for both response text and the reason-phrase fallback.
Redactor owner and provenance: The existing provider-error redactor removes active outgoing credentials, handles a truncated credential suffix, then applies the local short-Bearer supplement; blame attributes this owner surface to Peter Steinberger's current-main commit.
Findings None None.
Security None None.

Live Verification

Command: pnpm build && pnpm openclaw --help

Result: FAIL (failed) — step 1 expect_output Usage: openclaw: expected terminal output was not visible within 30 seconds: "Usage: openclaw"

$ node --import ./scripts/tsx.mjs scripts/build-all.mts
[build-all] plugins:assets:build
$ node --import ./scripts/tsx.mjs scripts/bundled-plugin-assets.mts --phase build
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 88.59 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[build-all] plugins:assets:build done in 1.51s
[build-all] tsdown-ai
[tsdown-build] invocation 1/1 finished in 3.2s
[build-all] tsdown-ai done in 3.66s
[build-all] tsdown-packages
[tsdown-build] invocation 1/1 finished in 14.7s
[build-all] tsdown-packages done in 15.2s
[build-all] tsdown-unified
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 1/9 finished in 10.6s

Assertions:

  • FAIL expect_output: Usage: openclaw

How this fits together

Bundled web-search plugins send authenticated HTTP requests through shared SDK helpers and return failures to agent tool callers. This change sanitizes provider-controlled failure text before it reaches those agent-facing error details.

flowchart LR
  A[Web search plugin request] --> B[Authenticated request headers]
  B --> C[Shared HTTP helper]
  B --> D[Perplexity request]
  C --> E[Failed provider response]
  D --> E
  E --> F[Request-aware credential redaction]
  F --> G[Agent-facing error details]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head hosted checks were still in progress in the supplied state; landing must wait for their successful completion.
Agent review details

Security

None.

PR surface

Source -18, Tests 0, Docs +4. Total -14 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 5 51 69 -18
Tests 6 141 141 0
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 196 210 -14

Review metrics

Metric Value Why it matters
Production versus test delta production −18, tests 0, docs +4 The fix reuses the existing error-redaction owner and removes duplicate xAI test-only surface rather than expanding production behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the request-local redaction after exact-head checks are green, retaining the existing two-argument helper contract and the shared redactor boundary.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the request-local redaction after exact-head checks are green, retaining the existing two-argument helper contract and the shared redactor boundary.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main visibly interpolates raw provider failure detail, and the PR documents a loopback before/after reproduction through the shared request path; this read-only review did not rerun contributor code.

Is this the best way to solve the issue?

Yes. Passing the actual outgoing headers into the existing request-aware redactor fixes the producer-side error boundary, covers shared-helper consumers, and keeps short-Bearer handling local to provider-controlled failures.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7b000dba9dab.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records before/after real loopback transport runs plus authenticated Perplexity and built-Gateway success/error evidence; redact private diagnostics if additional proof is posted.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The PR fixes credential exposure in provider-error details that can reach agent-visible diagnostics and logs during normal authenticated web-search failures.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records before/after real loopback transport runs plus authenticated Perplexity and built-Gateway success/error evidence; redact private diagnostics if additional proof is posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records before/after real loopback transport runs plus authenticated Perplexity and built-Gateway success/error evidence; redact private diagnostics if additional proof is posted.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current-main shared web-search helper/refactor and the maintainer rewrite at this PR head. (role: recent area contributor; confidence: high; commits: d77e2a5876b9, c853f369b47e; files: src/agents/tools/web-search-provider-common.ts, src/agents/provider-http-errors.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-07T11:43:06.128Z sha 982ec713d7d2486ab105968dae1c496e9edd1b84 :: needs real behavior proof before merge. :: [P1] Redact the status-text fallbacks
  • reviewed 2026-08-07T14:43:06.794Z sha f9d8cf7378c36e72481e9169fcaa17e95443921e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-09T13:48:28.500Z sha f9d8cf7378c36e72481e9169fcaa17e95443921e :: needs changes before merge. :: [P1] Redact short Bearer credentials in reason phrases
  • reviewed 2026-08-09T13:59:24.003Z sha f9d8cf7378c36e72481e9169fcaa17e95443921e :: needs changes before merge. :: [P1] Redact short Bearer credentials in reason phrases
  • reviewed 2026-08-09T15:55:55.067Z sha 2cc97f683f6cfc481b943e577d5b347fc23b3f4c :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T14:41:50.627Z sha 2cc97f683f6cfc481b943e577d5b347fc23b3f4c :: found issues before merge. :: [P2] Keep short Bearer masking out of the global payload redactor
  • reviewed 2026-08-21T12:22:59.877Z sha 2cc97f683f6cfc481b943e577d5b347fc23b3f4c :: needs changes before merge. :: [P2] Scope short Bearer masking to authenticated provider errors
  • reviewed 2026-08-27T12:53:18.198Z sha 2cc97f683f6cfc481b943e577d5b347fc23b3f4c :: found issues before merge. :: [P2] Keep short Bearer masking local to authenticated provider errors

@zenglingbiao
zenglingbiao force-pushed the fix/web-search-redact-error-body branch from 982ec71 to f9d8cf7 Compare August 7, 2026 14:35
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 7, 2026
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — exact-head CI is now green (the only remaining before-merge item). Thanks!

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@zenglingbiao zenglingbiao changed the title fix(agents): redact credentials reflected in web-search provider error bodies fix(agents): redact credentials from web-search error detail and statusText fallback Aug 9, 2026
@zenglingbiao zenglingbiao changed the title fix(agents): redact credentials from web-search error detail and statusText fallback fix(agents): redact reflected credentials from provider error detail and reason phrase Aug 9, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 9, 2026
@zenglingbiao
zenglingbiao force-pushed the fix/web-search-redact-error-body branch from f9d8cf7 to 2cc97f6 Compare August 9, 2026 15:30
@zenglingbiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review — the P1 short-Bearer finding is addressed at the forced tools-redaction boundary as recommended:

  • redactToolPayloadTextWithConfig() now also masks standalone Bearer credentials of 1–17 token characters (new STANDALONE_BEARER_SHORT_REDACT_PATTERN), so a short generic key in a provider-controlled reason phrase (empty-body 401 / Bearer abc) no longer reaches the error message. General log redaction keeps the 18-character prose floor unchanged.
  • The pattern's lookahead rejects the … ellipsis, so an already partially masked long token (Bearer abcdef…ghij) is never re-masked.
  • Added the requested short-token statusText regression cases for both shared helpers (throwWebSearchApiError and postTrustedWebToolsJson), plus boundary-contract tests in redact.test.ts.
  • Branch rebased onto current main; PR body updated with a fresh real-transport (node:http + undici) before/after proof covering the short-key reason-phrase case.

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 9, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 27, 2026

@steipete steipete left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep credential redaction at the provider request boundary

Thanks for covering both the response body and the reason-phrase fallback. This is a real gap that remains on current main, but this version both misses active credentials and broadens unrelated tool-diagnostic redaction.

Production LOC: +30/-5 (net +25) | Tests: +147/-0 | Total: +177/-5 (net +172).

Findings

  1. [P1] Redact the credential actually sent, including truncated reflections. postTrustedWebToolsJson already knows params.apiKey, but the new sanitizer receives only response text. A short/custom credential such as abcde, reflected as upstream refused abcde in either the body or an empty-body statusText, is neither a Bearer expression nor a recognizable vendor token. The process registry deliberately ignores values shorter than six characters (src/logging/secret-redaction-registry.ts:27), so it cannot close this gap. The patch also discards the truncated fact returned by readResponseText; a credential cut at maxErrorBytes will not match its registered full value. The request owner needs to carry the active credential and truncation context into error sanitization, rather than rely on generic pattern recognition.

  2. [P2] Do not apply short-Bearer guessing to unrelated tool diagnostics. The new pass in redactToolPayloadTextWithConfig applies to every caller, not just authenticated provider failures. The regex matches ordinary prose such as OAuth Bearer tokens are supported, replacing tokens with ***. Existing callers include compact tool displays (src/agents/tool-display-common.ts:128) and MCP diagnostics (src/agents/mcp-error.ts:22). Keep provider-error handling scoped to that boundary. Current main also separates model-visible source text from diagnostic redaction; the older shared-policy shape in this diff should not undo that distinction when refreshed.

Best-fix verdict: too broad in logging, too narrow at the credential owner. Reuse createProviderErrorTextRedactor in src/agents/provider-http-errors.ts:42, which already removes active request credentials and handles a truncated credential suffix. Consolidate the two web-search error paths and carry the same request context through both Perplexity call sites (extensions/perplexity/src/perplexity-web-search-provider.runtime.ts:250,298). The native PDF and MiniMax VLM paths from #125499 demonstrate that existing boundary. A global short-token heuristic is not necessary to connect web search to it, and registry-only matching cannot cover short values or partial reflections.

Please retain focused owner-boundary proof for complete and partial bare credentials, body/status fallback, ordinary Bearer prose, and both Perplexity transports. Collapse the duplicate error handling and repeated test setup into the existing owners, targeting a non-positive total diff; I have not demonstrated that final rewrite or its LOC count yet.

Evidence and limits: Reviewed head 2cc97f683f6cfc481b943e577d5b347fc23b3f4c, the shared request/error owners, Tavily and xAI callers, both Perplexity transports, the bounded body reader, generic redaction/registry, and PDF/VLM siblings. The raw web-search error branches remain unchanged on main 53380e5ca735dd8d6a42fc74d4f441068d629f89 and stable tag v2026.7.1-2; this is not an already-fixed close. Original introduction was not independently established because local blame stops at a shallow-history boundary. These findings are source-derived: I have not executed this PR or independently reproduced its reported HTTP run.

@steipete steipete self-assigned this Aug 27, 2026
Bind bounded error diagnostics to the actual outgoing request headers for
shared web tools and both Perplexity transports. Preserve caller cancellation
and replace case-insensitive owned headers without combining credentials.

Reuse the provider error redactor and remove duplicate xAI parser-only test
paths while retaining real HTTP and sibling coverage. Production -18 lines;
total -14 lines including regression tests and documentation.

Refs openclaw#120200, openclaw#117304, openclaw#119536.

Co-authored-by: zenglingbiao <[email protected]>
@steipete
steipete force-pushed the fix/web-search-redact-error-body branch from 2cc97f6 to c853f36 Compare August 27, 2026 21:30
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: perplexity extensions: xai size: M and removed size: S labels Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

Rewrote this PR at c853f369b47ea95feb8e410cc6a29ba2d20dc0bb, preserving @zenglingbiao's co-authorship.

The short-credential policy is now request-local and reuses the existing provider-error redactor; global payload text is untouched. Both Perplexity transports carry their actual headers. Review also caught combined mixed-case Authorization values, fixed at request construction, and the regression suite protects caller cancellation during error-body reads.

The updated PR body records the failing/passing HTTP reproductions, 230 passing focused/sibling tests, green full build and changed gates, and real authenticated Perplexity plus built-Gateway success/error proof. Production is −18 lines and the complete PR is −14 including tests/docs. Exact-head hosted CI is running; native landing remains pending.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 27, 2026
Prevent early SIGTERM from orphaning a detached compiler before its supervisor
registers the child. Retain shared handlers for concurrent commands and clean
them up after synchronous or asynchronous spawn failure.

Reproduce the race at the real process boundary and consolidate stale type
comments and one-use registration wrappers.
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: L and removed size: M labels Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

The takeover is now at b66c19a. The twelve web-fix files are unchanged from the preceding built, live-tested head.

The first hosted run exposed a real existing startup race in the shared process supervisor: the detached compiler could publish readiness before the supervisor installed its OS signal handlers. An early SIGTERM then killed the supervisor without reaping its compiler. The fix moves handler installation to before spawn and retains correct cleanup for concurrent commands and spawn failures. A deterministic real-process probe and the tracked regression fail with the old ordering and pass after the repair; no timeout was increased.

The additional 91 tooling/helper tests, local changed-file gate, and fresh isolated Codex P0 review passed. The complete PR is now production −92, tests +55, docs +4, total −33 lines. Contributor credit is retained. Exact-head CI is running; native landing remains held until it is green. The PR body includes the earlier authenticated provider/Gateway proof and the distinct unproven process-owner follow-up.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete steipete left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier change request on 2cc97f is addressed by the maintainer rewrite at b66c19a.

The shared authenticated request owner now passes actual outgoing headers and truncation context to the existing provider-error redactor. Short and partial credential reflections are covered without changing global tool-prose redaction. Perplexity's native and Sonar/OpenRouter paths carry the same context. Mixed-case Authorization replacement and post-header cancellation are regression-tested. The request-local design and removal of duplicate xAI test-only surface are the appropriate owner-boundary fix.

The first hosted run exposed a separate real managed-process startup race. Installing signal handlers before spawning repairs it without increased timeouts; the real-process regression fails with the old ordering and passes after the repair. Shared-listener and failed-spawn cleanup are covered.

Verification: 230 web/provider/sibling tests, 91 tooling/helper tests, complete local changed gates, full build, final-head CLI help, authenticated Perplexity Search/Sonar, real invalid-key Perplexity/Tavily, and isolated built-Gateway success/error flows. The final assembled 15-file isolated Codex review has no actionable P0 findings; maintainer and independent source review separately cover lower-priority correctness. Exact-head CI33121764838 passed: 185 jobs succeeded and 17 were skipped, with no failures; the formerly failing small-47 job and ci-gate both succeeded. All application file blobs are unchanged from the built/live-tested rewrite.

Production −92, tests +55, docs +4: total −33 lines. Contributor credit is preserved. No authenticated Tavily success or xAI live call is claimed; named Exa/Parallel and separate process-owner follow-ups remain outside this repair. Native artifact validation and prepare completed successfully without rebasing; the prepared source stayed exact b66c19a. Hosted CI33121764838 and Workflow Sanity33121764858 satisfied the native gate; no additional Testbox was needed. Native merge completed as 213804d7. All 15 landed file blobs independently match the reviewed head; main ancestry, native worktree/ref/lock cleanup and preservation of unrelated checkouts were verified.

@steipete
steipete merged commit 213804d into openclaw:main Aug 27, 2026
271 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…and reason phrase (openclaw#120200)

* fix(web): redact request credentials from provider errors

Bind bounded error diagnostics to the actual outgoing request headers for
shared web tools and both Perplexity transports. Preserve caller cancellation
and replace case-insensitive owned headers without combining credentials.

Reuse the provider error redactor and remove duplicate xAI parser-only test
paths while retaining real HTTP and sibling coverage. Production -18 lines;
total -14 lines including regression tests and documentation.

Refs openclaw#120200, openclaw#117304, openclaw#119536.

Co-authored-by: zenglingbiao <[email protected]>

* fix(tooling): install managed signals before spawning children

Prevent early SIGTERM from orphaning a detached compiler before its supervisor
registers the child. Retain shared handlers for concurrent commands and clean
them up after synchronous or asynchronous spawn failure.

Reproduce the race at the real process boundary and consolidate stale type
comments and one-use registration wrappers.

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: perplexity extensions: xai P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants