Skip to content

fix(qqbot): reject open HTTP error bodies during debug capture - #119466

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
xialonglee:fix/gap-qqbot-media-tee-cancel-hang
Aug 5, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
xialonglee:fix/gap-qqbot-media-tee-cancel-hang

Conversation

@xialonglee

@xialonglee xialonglee commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where QQ Bot media uploads from a URL could hang instead of returning an upstream HTTP error when debug proxy capture retained an open clone of the response body.

Why This Change Was Made

downloadDirectUploadUrl now starts cancellation of a non-OK response body without awaiting the tee-bound cancellation promise, then throws the HTTP error while the existing finally block releases the guarded dispatcher. The regression test uses a native open ReadableStream, Response.clone(), and the original cancel() implementation to prove the capture sibling cannot block the caller.

Regression provenance: #110008, squash commit 17643f385085d68d104d216eae1a08785da4b3ec, added the awaited cancellation that becomes pending when debug capture owns the sibling tee branch.

User Impact

Operators using QQ Bot URL media uploads receive the upstream HTTP 4xx/5xx failure promptly under debug capture instead of an indefinitely pending upload. No QQ API request or token lookup runs after the download error.

Evidence

  • Deterministic red/green tee proof:
    • With the repaired fire-and-forget cancellation, the focused QQ Bot suite passes.
    • Temporarily restoring await response.body?.cancel() makes the regression test fail on the next setImmediate turn because the native tee cancellation is still pending.
  • Real debug-capture proof:
    • A local HTTP server returned an HTTP 500 body and intentionally kept it open.
    • downloadDirectUploadUrl rejected with Direct-upload media URL returned HTTP 500 in 182 ms.
    • At rejection time, capture contained only the redacted request event; after the server ended the body, the response event completed and remained redacted.
  • Local focused proof:
    • node scripts/run-vitest.mjs extensions/qqbot/src/engine/api/media.test.ts src/proxy-capture/runtime.test.ts
    • 40 tests passed across 2 Vitest shards.
    • oxfmt --check and git diff --check passed.
  • Blacksmith Testbox:
  • P1 autoreview: no findings; patch correct with 0.96 confidence.

Production delta: +4/-1. Test delta: +68/-0. No config, SDK, protocol, storage, migration, or product-boundary change.

Punchcard-Session: clear-orchard-lantern-bc

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 4:19 AM ET / 08:19 UTC.

ClawSweeper review

What this changes

The PR makes QQ Bot URL-media downloads return non-OK HTTP errors without waiting for a debug-capture response clone to finish cancellation.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings. Current main still awaits a tee-bound cancellation in this QQ Bot path, while this PR applies the existing nonblocking cancellation pattern with a focused native-stream regression test; it remains necessary and ready for maintainer review after a merge-result refresh.

Priority: P2
Reviewed head: 6e739b2733b0da0919e228fdb90d4f0ba5dc662a

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow root-cause repair with a native tee regression test and concrete after-fix debug-capture evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies an after-fix local HTTP-server run under debug capture with a 182 ms error result and redacted capture outcome; the prepared media URL is only test input and its unavailable download does not undermine that copied live proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies an after-fix local HTTP-server run under debug capture with a 182 ms error result and redacted capture outcome; the prepared media URL is only test input and its unavailable download does not undermine that copied live proof.
Evidence reviewed 9 items Current-main failure point: Current main awaits cancellation before throwing for a non-OK direct-upload response, so a pending clone-tee cancellation blocks the visible error.
Exact PR repair: The production commit starts the same cancellation without awaiting it, then preserves the existing error and guarded-dispatcher release flow.
Capture contract: The debug-capture runtime documents that cancelling one Response.clone tee branch settles only after both branches cancel, and therefore uses fire-and-forget cancellation itself.
Findings None None.
Security None None.

How this fits together

QQ Bot fetches a supplied media URL through an SSRF-protected downloader before acquiring a QQ token or uploading media. Debug proxy capture clones HTTP responses for redacted diagnostics, so a failed download must not wait on the clone branch before returning its error.

flowchart LR
  A[QQ Bot media URL] --> B[SSRF-protected fetch]
  B --> C[Debug capture clone]
  B --> D[QQ Bot downloader]
  D --> E{HTTP response OK?}
  E -->|No| F[Cancel body without blocking]
  F --> G[Return HTTP error]
  E -->|Yes| H[Read media and upload]
Loading

Before merge

  • Resolve merge risk (P1) - This branch is behind current main; GitHub reports it mergeable, but refresh the three-way merge result and exact-head checks before landing.
  • Complete next step (P2) - No repair lane is needed; review the clean three-way merge result against current main before landing.
Agent review details

Security

None.

PR surface

Source +3, Tests +68. Total +71 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 68 0 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 72 1 +71

Review metrics

Metric Value Why it matters
Production vs regression LOC production +3 net (+4/-1), tests +68 The production growth is an inline lifecycle-invariant explanation; the test addition covers the previously missing native tee execution order.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the owner-local nonblocking cancellation after an exact current-main merge/check refresh, while retaining the existing capture clone reader and SSRF-guard dispatcher cleanup.
  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 owner-local nonblocking cancellation after an exact current-main merge/check refresh, while retaining the existing capture clone reader and SSRF-guard dispatcher cleanup.

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

Yes. Current main awaits cancellation at the affected error branch, and the exact-head native Response.clone regression test provides a concrete open-stream path showing why that promise can remain pending.

Is this the best way to solve the issue?

Yes. The downloader owns the prompt error outcome and must not await tee-bound cleanup; the change preserves best-effort cancellation and the existing dispatcher release rather than adding a fallback or timeout.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 26a58bcd92ba.

Labels

Label justifications:

  • P2: This fixes a bounded but user-visible QQ Bot URL-media error path that can hang when debug capture is enabled.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies an after-fix local HTTP-server run under debug capture with a 182 ms error result and redacted capture outcome; the prepared media URL is only test input and its unavailable download does not undermine that copied live proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an after-fix local HTTP-server run under debug capture with a 182 ms error result and redacted capture outcome; the prepared media URL is only test input and its unavailable download does not undermine that copied live proof.

Evidence

What I checked:

Likely related people:

  • Monkey-wusky: Authored the merged direct-upload cancellation repair whose changed blob is still present in current main. (role: introduced the preceding cancellation behavior; confidence: high; commits: 17643f385085; files: extensions/qqbot/src/engine/api/media.ts)
  • Peter Steinberger: The latest current-main history sampled for the QQ Bot media path includes this contributor's commit, and adjacent current-main capture behavior follows the same cancellation invariant. (role: recent area contributor; confidence: medium; commits: bf1bdb429ece; files: extensions/qqbot/src/engine/api/media.ts, src/proxy-capture/runtime.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 (3 earlier review cycles)
  • reviewed 2026-08-05T04:11:59.638Z sha 693216d :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T07:34:34.240Z sha 693216d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T08:06:49.256Z sha 6e739b2 :: needs maintainer review before merge. :: none

@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof with debug capture enabled has been added to the PR body.

@clawsweeper

clawsweeper Bot commented Aug 5, 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:

Punchcard-Session: clear-orchard-lantern-bc
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@vincentkoc vincentkoc changed the title fix(qqbot): URL media upload hangs on HTTP error under debug proxy fix(qqbot): reject open HTTP error bodies during debug capture Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The head changed to replace the synthetic cancellation mock with a native open Response.clone() tee regression test. The PR body now contains the exact-head local, real debug-capture, Blacksmith Testbox, and P1 autoreview evidence.

@clawsweeper

clawsweeper Bot commented Aug 5, 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:

@vincentkoc

Copy link
Copy Markdown
Member

Land-ready verification:

Production delta: +4/-1; tests: +68/-0. No remaining proof gap.

@vincentkoc
vincentkoc merged commit 81238d0 into openclaw:main Aug 5, 2026
96 of 98 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

@xialonglee
xialonglee deleted the fix/gap-qqbot-media-tee-cancel-hang branch August 5, 2026 09:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
…law#119466)

* fix(qqbot): cancel rejected direct-upload body fire-and-forget under debug proxy

* test(qqbot): prove capture tee cancellation stays non-blocking

Punchcard-Session: clear-orchard-lantern-bc

---------

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

Labels

channel: qqbot P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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