Skip to content

fix(qqbot): add timeout to remote media URL fetches - #103018

Merged
sallyom merged 10 commits into
openclaw:mainfrom
Alix-007:alix/qqbot-remote-media-fetch-timeout
Jul 12, 2026
Merged

sallyom merged 10 commits into
openclaw:mainfrom
Alix-007:alix/qqbot-remote-media-fetch-timeout

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

QQBot remote media downloads accepted HTTPS media URLs and delegated them through the platform media adapter without a response-header deadline. If a remote media host accepted the connection but never sent headers, inbound attachment handling or outbound remote-media send preparation could wait indefinitely.

Why This Change Was Made

The shared media runtime now has a responseHeaderTimeoutMs contract for stalled-header protection. This PR wires QQBot's media adapter contract through to that runtime and gives downloadFile() a 120s response-header deadline while preserving the existing HTTPS and SSRF policy checks.

This deliberately does not use timeoutMs for the QQBot 120s deadline, because timeoutMs caps the complete fetch/body operation and can break slow-but-progressing media downloads after headers arrive.

User Impact

QQBot media URLs that stall before response headers now fail and return null through the existing error path instead of wedging the media pipeline forever. Slow response bodies can continue through the existing media runtime body handling after headers arrive.

Evidence

Exact head: 2a5ab12210ce48a1925620a7bcc621de2daa7716

Current-head validation:

  • Focused tests: node scripts/run-vitest.mjs extensions/qqbot/src/engine/utils/file-utils.test.ts extensions/qqbot/src/bridge/bootstrap.test.ts -> 2 files, 7 tests passed.
  • Format: node_modules/.bin/oxfmt --check --threads=1 extensions/qqbot/src/engine/adapter/types.ts extensions/qqbot/src/bridge/bootstrap.ts extensions/qqbot/src/bridge/bootstrap.test.ts extensions/qqbot/src/engine/utils/file-utils.ts extensions/qqbot/src/engine/utils/file-utils.test.ts -> passed.
  • Lint: node_modules/.bin/oxlint --threads=1 extensions/qqbot/src/engine/adapter/types.ts extensions/qqbot/src/bridge/bootstrap.ts extensions/qqbot/src/bridge/bootstrap.test.ts extensions/qqbot/src/engine/utils/file-utils.ts extensions/qqbot/src/engine/utils/file-utils.test.ts -> passed.
  • Whitespace: git diff --check -> clean.
  • Types: node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental false --pretty false -> passed.
  • Autoreview: env -u OPENAI_API_KEY -u OPENAI_ORG_ID -u OPENAI_PROJECT_ID .agents/skills/autoreview/scripts/autoreview --mode local -> passed with no findings.

Current-head behavior coverage:

  • extensions/qqbot/src/engine/utils/file-utils.test.ts asserts downloadFile() passes responseHeaderTimeoutMs: 120_000 together with QQBOT_MEDIA_SSRF_POLICY to the platform adapter.
  • extensions/qqbot/src/bridge/bootstrap.test.ts asserts the built-in bridge adapter forwards responseHeaderTimeoutMs through to readRemoteMediaBuffer().
  • src/media/fetch.ts on current main owns the response-header timer and clears only that timer after headers arrive; this PR does not add a duplicate core media path.

Previously accepted real behavior proof:

  • At previous exact head fb6cf168380c2894040fc279aa1bfa203b8e95e7, the local stalled HTTPS harness exercised production downloadFile() from extensions/qqbot/src/engine/utils/file-utils.ts, the built-in adapter from extensions/qqbot/src/bridge/bootstrap.ts, the media runtime, the SSRF guard, a real HTTPS/TLS connection, and the production 120000ms abort path.
  • That harness used https://media.qq.com:<port>/redacted/photo.png, mapped media.qq.com to 198.18.0.1, enabled the QQBot RFC2544 SSRF allowance, withheld response headers, observed the client abort after the 120s deadline, returned downloadFile.result=null, and wrote zero files.
  • Current-head rerun of that exact local network harness was blocked by the container network permissions: ip addr add 198.18.0.1/32 dev lo returned RTNETLINK answers: Operation not permitted. The current-head focused tests above cover the code difference from that accepted proof: the 120s deadline now lands in responseHeaderTimeoutMs instead of timeoutMs.

What was not tested: live QQBot traffic. No QQBot token, media ID, or secret was used.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 12, 2026, 6:08 AM ET / 10:08 UTC.

Summary
The PR extends QQBot’s media adapter timeout options, forwards them to the shared media runtime, applies a 120-second response-header deadline to remote downloads, and adds focused regression tests.

PR surface: Source +9, Tests +37. Total +46 across 5 files.

Reproducibility: yes. at high source confidence. Current main routes inbound attachments and outbound URL fallback through a QQBot helper with no response-header deadline, while the supplied stalled-HTTPS run exercised the production path and expected timeout outcome after the fix.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • No automated repair is needed; maintainers can use the normal landing workflow for this proven, clean patch.

Security
Cleared: The patch adds no dependency, workflow, permission, credential, artifact-execution, or new fetch path and preserves the existing HTTPS and SSRF boundary.

Review details

Best possible solution:

Land the QQBot-owned 120-second response-header deadline through the existing shared media runtime, preserving current HTTPS, SSRF, progressing-body, and null-return behavior.

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

Yes at high source confidence. Current main routes inbound attachments and outbound URL fallback through a QQBot helper with no response-header deadline, while the supplied stalled-HTTPS run exercised the production path and expected timeout outcome after the fix.

Is this the best way to solve the issue?

Yes. A response-header-only deadline is the narrowest maintainable solution because it reuses the canonical runtime, does not cap healthy progressing bodies, and keeps QQBot-specific policy in the owning plugin.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded QQBot media reliability bug with limited channel-specific blast radius and no evidence of an emergency or repository-wide regression.
  • 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): A stalled HTTPS harness exercised the production QQBot helper, built-in adapter, shared media runtime, SSRF guard, abort, null return, and zero-file outcome; focused tests cover the later switch to responseHeaderTimeoutMs.
  • proof: sufficient: Contributor real behavior proof is sufficient. A stalled HTTPS harness exercised the production QQBot helper, built-in adapter, shared media runtime, SSRF guard, abort, null return, and zero-file outcome; focused tests cover the later switch to responseHeaderTimeoutMs.
Evidence reviewed

PR surface:

Source +9, Tests +37. Total +46 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 9 0 +9
Tests 2 37 0 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 46 0 +46

What I checked:

Likely related people:

  • cxyhhhhh: Authored the major QQBot engine extraction and later group-chat/media architecture refactor that established the current helper and adapter structure. (role: feature owner; confidence: high; commits: 5e72e39c1852, 5ccf179a34a9; files: extensions/qqbot/src/engine/utils/file-utils.ts, extensions/qqbot/src/bridge/bootstrap.ts)
  • steipete: Authored the recent shared bounded-media refactor and multiple QQBot helper/runtime changes that define the adapter-to-media-runtime boundary used here. (role: recent area contributor; confidence: high; commits: 53d007bc878c, 6a4069dead0f, a607661a71d8; files: extensions/qqbot/src/bridge/bootstrap.ts, extensions/qqbot/src/engine/utils/file-utils.ts, src/media/fetch.ts)
  • drobison00: Introduced the bundled QQBot extension in commit 37d7c716, making them relevant to the original channel implementation history. (role: introduced behavior; confidence: medium; commits: 37d7c716f420; files: extensions/qqbot/src/engine/utils/file-utils.ts)
  • Alix-007: Previously landed the shared responseHeaderTimeoutMs media contract through the Telegram stalled-download fix, providing merged history on the exact runtime behavior reused here. (role: adjacent contract contributor; confidence: medium; commits: 26aef8c48bc4; files: src/media/fetch.ts, src/media/fetch.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (4 earlier review cycles)
  • reviewed 2026-07-09T17:23:32.245Z sha e3c0363 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T15:57:33.286Z sha fb6cf16 :: needs changes before merge. :: [P1] Use the header-only timeout for this stall
  • reviewed 2026-07-10T16:55:40.873Z sha 2a5ab12 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-12T01:57:25.331Z sha fb8178e :: needs maintainer review before merge. :: none

@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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 9, 2026
@Alix-007

Alix-007 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR body with exact-head real behavior proof for fb6cf168380c2894040fc279aa1bfa203b8e95e7.

The new proof uses the built-in QQBot adapter and production downloadFile() path against a real stalled HTTPS server. media.qq.com was temporarily mapped to RFC2544 loopback 198.18.0.1, the server accepted the TLS GET and withheld headers, fetchWithSsrFGuard timed out at the production 120000ms deadline, downloadFile returned null, and no file was written.

Known proof limitation is explicit in the body: certificate verification was disabled only for the local self-signed TLS harness. The timeout, SSRF, built-in adapter, media runtime, HTTPS connection, abort, and null-return path are exercised.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 10, 2026
@Alix-007
Alix-007 force-pushed the alix/qqbot-remote-media-fetch-timeout branch from ea09988 to 2a5ab12 Compare July 10, 2026 16:24
@Alix-007

Copy link
Copy Markdown
Contributor Author

ClawSweeper update for latest head 2a5ab12210ce48a1925620a7bcc621de2daa7716:

  • Rebased/merged current main into the branch so the existing core responseHeaderTimeoutMs media seam is present.
  • Changed QQBot remote media downloads from timeoutMs: 120_000 to responseHeaderTimeoutMs: 120_000, so the 120s deadline only covers stalled final response headers and no longer caps slow-but-progressing body reads.
  • Added extensions/qqbot/src/bridge/bootstrap.test.ts to prove the built-in adapter forwards responseHeaderTimeoutMs to readRemoteMediaBuffer().
  • Updated extensions/qqbot/src/engine/utils/file-utils.test.ts to prove downloadFile() passes the QQBot SSRF policy plus responseHeaderTimeoutMs: 120_000 to the platform adapter.

Validation on the current head:

node scripts/run-vitest.mjs extensions/qqbot/src/engine/utils/file-utils.test.ts extensions/qqbot/src/bridge/bootstrap.test.ts -> 2 files, 7 tests passed
node_modules/.bin/oxfmt --check --threads=1 extensions/qqbot/src/engine/adapter/types.ts extensions/qqbot/src/bridge/bootstrap.ts extensions/qqbot/src/bridge/bootstrap.test.ts extensions/qqbot/src/engine/utils/file-utils.ts extensions/qqbot/src/engine/utils/file-utils.test.ts -> passed
node_modules/.bin/oxlint --threads=1 extensions/qqbot/src/engine/adapter/types.ts extensions/qqbot/src/bridge/bootstrap.ts extensions/qqbot/src/bridge/bootstrap.test.ts extensions/qqbot/src/engine/utils/file-utils.ts extensions/qqbot/src/engine/utils/file-utils.test.ts -> passed
git diff --check -> clean
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental false --pretty false -> passed
env -u OPENAI_API_KEY -u OPENAI_ORG_ID -u OPENAI_PROJECT_ID .agents/skills/autoreview/scripts/autoreview --mode local -> passed with no findings

I tried to rerun the exact stalled HTTPS harness at the new head, but this container cannot add the RFC2544 loopback alias used by the previous accepted proof (ip addr add 198.18.0.1/32 dev lo returns RTNETLINK answers: Operation not permitted). The PR body now records that limit and the current-head focused coverage for the changed field/forwarding path.

Please rerun the review on the latest head.

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Latest head 2a5ab12210ce48a1925620a7bcc621de2daa7716 addresses the previous timeoutMs finding by using responseHeaderTimeoutMs: 120_000 and adds focused forwarding coverage. Detailed evidence: #103018 (comment)

@clawsweeper

clawsweeper Bot commented Jul 10, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 10, 2026
…edia-fetch-timeout

# Conflicts:
#	extensions/qqbot/src/bridge/bootstrap.test.ts
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 12, 2026
@sallyom

sallyom commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Maintainer review: merge-ready. Clean review; this fixes a real QQBot remote-media header stall at the existing owner boundary by forwarding a 120-second response-header-only deadline through the shared guarded-media runtime. This is the narrow fix: it preserves HTTPS/SSRF behavior and does not cap slow-but-progressing response bodies. No breaking change; the only behavior tightening is that stalled header fetches now fail instead of hanging. Exact head: b12c763e2bacae85b22ec556e0584d30e86ca58a. CI is green with no failed or pending checks.

@sallyom sallyom self-assigned this Jul 12, 2026
@sallyom
sallyom merged commit 2f3517c into openclaw:main Jul 12, 2026
96 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 13, 2026
* fix(qqbot): add timeout to remote media URL fetches

* fix(qqbot): use response header media timeout

---------

Co-authored-by: llagy009 <[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: XS 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.

3 participants