Skip to content

fix(qqbot): honor the configured upgradeUrl in /bot-upgrade - #119357

Closed
ayaangazali wants to merge 4 commits into
openclaw:mainfrom
ayaangazali:fix/qqbot-honor-upgrade-url
Closed

ayaangazali wants to merge 4 commits into
openclaw:mainfrom
ayaangazali:fix/qqbot-honor-upgrade-url

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

What Problem This Solves

channels.qqbot.upgradeUrl is documented by its own type as the URL the /bot-upgrade command returns, and the command ignores it.

extensions/qqbot/src/types.ts:105-108:

/**
 * Upgrade guide URL returned by `/bot-upgrade`.
 */
upgradeUrl?: string;

extensions/qqbot/src/engine/commands/builtin/register-basic.ts, before this change:

handler: () =>
  [`📘 QQBot 升级指引:`, `[点击查看升级说明](${QQBOT_UPGRADE_GUIDE_URL})`].join("\n"),

The handler takes no context and always emits the bundled constant, so an operator who points upgradeUrl at their own internal upgrade runbook still sees the public q.qq.com link. The key validates, openclaw config get echoes it back, and it changes nothing. Nothing anywhere in the repo reads it: outside the schema and the type declaration there are no references to upgradeUrl in extensions/qqbot or in core.

This is the silent class rather than a loud one. There is no error to tell the operator the setting is inert, and the command still answers confidently with the wrong URL, which is worse than not answering.

Why This Change Was Made

The fix is to read the key that already exists rather than to add surface. The handler now takes ctx and prefers the configured URL, falling back to the bundled guide:

const configuredUrl =
  typeof ctx.accountConfig?.upgradeUrl === "string"
    ? normalizeOptionalString(ctx.accountConfig.upgradeUrl)
    : undefined;

ctx.accountConfig was already available to handlers and is used the same way by sibling commands (register-streaming.ts:37 reads ctx.accountConfig?.streaming, register-group-allways.ts:32 reads ctx.accountConfig?.defaultRequireMention), so this follows the established shape rather than inventing one. accountConfig is typed Record<string, unknown>, so the value is narrowed with the existing normalizeOptionalString helper instead of a cast; a blank or whitespace-only value falls back to the default rather than emitting an empty link.

No config, schema, or default surface changes. The behavior only differs for operators who had already set the key, and for them it starts doing what its documentation says.

One thing I did not fix, on purpose

upgradeMode (extensions/qqbot/src/types.ts:110-114) is the sibling key, and it is inert in a way I did not want to resolve unilaterally:

/**
 * Upgrade command mode.
 * - "doc": show an upgrade guide link
 * - "hot-reload": run an in-place npm update flow
 */
upgradeMode?: "doc" | "hot-reload";

The "doc" behavior is what the command already does. The "hot-reload" in-place npm update flow does not exist anywhere in the plugin. Making it real is a feature with obvious safety questions (a bot command that runs an in-place package update), and quietly deleting a documented mode is a product call, so both belong with a maintainer rather than in this PR. Happy to follow up either way once you say which.

User Impact

Operators who set channels.qqbot.upgradeUrl, for example to an internal runbook, now get that URL from /bot-upgrade. Everyone else sees the same bundled guide as before.

Evidence

node scripts/run-vitest.mjs extensions/qqbot: 86 files / 767 tests passing.

Two cases added to slash-commands-impl.test.ts drive the real registered command through SlashCommandRegistry rather than calling a helper: one asserts a configured URL is returned and the bundled constant is absent, one asserts the fallback for both an unset key and a whitespace-only value.

I checked the test actually pins the behavior by breaking the fix on purpose (forcing configuredUrl to undefined) and re-running:

× returns the operator-configured upgrade url
Tests  1 failed | 13 passed (14)

then restored it and got 14/14.

Gates: check-extension-package-tsc-boundary.mjs exit 0, generate-bundled-channel-config-metadata.ts --check clean, oxlint clean on both changed files, git diff --check clean.

Worth noting that the boundary check earned its keep here. My first version used ctx.accountConfig?.upgradeUrl?.trim(), which passes Vitest (no typecheck) but fails TS2339: Property 'trim' does not exist on type '{}' because accountConfig is Record<string, unknown>. The narrowing above is the fix.

AI-assisted: written with AI assistance. I read the command registry, the handler, the sibling commands that consume accountConfig, and the type declarations myself, and ran the tests, the deliberate-break check, and the gates locally.

@ayaangazali
ayaangazali marked this pull request as ready for review August 4, 2026 22:01
Copilot AI lite review requested due to automatic review settings August 4, 2026 22:01

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 11, 2026, 6:03 AM ET / 10:03 UTC.

ClawSweeper review

What this changes

The PR makes /bot-upgrade return an authorized account’s configured QQBot guide URL, otherwise retaining the bundled public guide, with documentation and regression tests.

Regression provenance

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

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

The PR fixes a real current-main QQBot configuration defect at the command owner and preserves the public guide for unauthorised C2C senders. No code finding remains; redacted real delivery proof is still required before merge.

Priority: P2
Reviewed head: fe64c71d5dff0b991acfa50fdc7e115a50429776

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair and regression coverage are strong, but real behavior proof remains the merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The new tests use the real command dispatch seam but mock the QQBot sender; add redacted C2C output or a qualifying mock-gateway verdict before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The new tests use the real command dispatch seam but mock the QQBot sender; add redacted C2C output or a qualifying mock-gateway verdict before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current-main defect: Current main accepts upgradeUrl in the QQBot account schema, but /bot-upgrade always returns the bundled URL and never reads that setting.
Command-owner repair: The PR reads the resolved account value only after the existing authorization result, normalizes blank strings, and otherwise uses the public fallback.
Authorization and delivery boundary: The dispatcher derives commandAuthorized using explicit non-wildcard entries, then passes it and the account configuration into the command context before sending the reply.
Findings None None.
Security None None.

How this fits together

QQBot turns a C2C slash command into an outbound reply using the resolved account configuration and command authorization result. The configured guide may be an internal operator runbook, so the command must select it only for explicitly authorized senders.

flowchart LR
  A[C2C /bot-upgrade] --> B[QQBot command dispatcher]
  B --> C[Explicit authorization check]
  C --> D[Guide selection]
  E[Resolved account configuration] --> D
  F[Bundled public guide] --> D
  D --> G[Outbound C2C reply]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The new tests use the real command dispatch seam but mock the QQBot sender; add redacted C2C output or a qualifying mock-gateway verdict before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - A configured guide can be a private runbook; the branch has not yet shown the authorization decision and resulting text through a real QQBot delivery boundary.
  • Resolve merge risk (P1) - Production code grows by 13 net lines. That is justified by the context-aware authorization and normalization boundary; a net-neutral form would collapse the security condition into an opaque inline expression.
  • Complete next step (P2) - The remaining action is contributor-supplied delivery proof, not a mechanical repair task.
Agent review details

Security

None.

PR surface

Source +15, Tests +132, Docs +7. Total +154 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 2 +15
Tests 2 132 0 +132
Docs 1 8 1 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 157 3 +154

Review metrics

Metric Value Why it matters
Production versus test LOC production +15/-2 (net +13); tests +132/-0; docs +8/-1 The repair adds one security-sensitive response decision with handler and dispatch regression coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/qqbot/src/engine/commands/builtin/register-basic.upgrade.test.ts, migration/backfill/repair: extensions/qqbot/src/engine/commands/slash-commands-impl.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Add delivery-boundary proof (recommended)
    Attach a redacted QQBot C2C result or qualifying mock-gateway verdict showing both the authorized configured-guide and unauthorised public-guide paths.

Technical review

Best possible solution:

Retain the clear command-boundary gate and attach redacted evidence that an authorized C2C sender receives the configured URL while an unauthorised sender receives the bundled public guide.

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

Yes—current main accepts upgradeUrl but the handler at extensions/qqbot/src/engine/commands/builtin/register-basic.ts:93 always emits the bundled guide; the PR changes that exact decision.

Is this the best way to solve the issue?

Yes—the command handler owns the reply text, already receives both the resolved account configuration and authorization fact, and avoids adding a second policy path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs a documented QQBot configuration defect with limited channel-specific blast radius.
  • merge-risk: 🚨 security-boundary: The changed response can disclose an operator-owned guide URL unless the authorization boundary remains correct.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The new tests use the real command dispatch seam but mock the QQBot sender; add redacted C2C output or a qualifying mock-gateway verdict before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: The available local blame boundary carries the current command lines, though it cannot establish original authorship. (role: recent current-main carrier; confidence: low; commits: a8839a89239a; files: extensions/qqbot/src/engine/commands/builtin/register-basic.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-fix QQBot C2C output or a qualifying mock-gateway verdict artifact for both authorization outcomes.

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 (5 earlier review cycles)
  • reviewed 2026-08-04T22:08:11.002Z sha 589212d78d8c24a69a6d2762d114940f22b12ce6 :: needs real behavior proof before merge. :: none
  • reviewed August 4, 2026, 8:23 PM ET / August 5, 2026, 00:23 UTC sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-05T11:17:00.125Z sha 7a48d68ec1b5e1b5d41b1e2a5cc517982c3ce4e0 :: needs real behavior proof before merge. :: [P3] Document the activated QQBot upgradeUrl setting
  • reviewed 2026-08-10T02:48:20.762Z sha 69033a79ae17b1179224530f9fb8275561f749fb :: needs real behavior proof before merge. :: [P1] Do not reveal custom guides to unauthorised C2C senders
  • reviewed 2026-08-10T16:55:10.622Z sha b6c6b61e4bc091052f8dcd983d863a75fcf16f18 :: needs real behavior proof before merge. :: none

@ayaangazali

Copy link
Copy Markdown
Contributor Author

CI is red here on build-artifacts (and openclaw/ci-gate downstream of it), and I do not think it is this diff. Evidence rather than assertion:

All six failures are in one suite, src/tui/tui-pty-local.e2e.test.ts, under "TUI PTY real backends > with shared Gateway fixture":

GatewayClientRequestTimeoutError: gateway request timeout for chat.history
Serialized Error: { method: 'chat.history', timeoutMs: 30000, requestSent: true }
Serialized Error: { method: 'sessions.create', timeoutMs: 30000, requestSent: true }
Error: Test timed out in 150000ms.
Test Files  1 failed | 2 passed (3)
     Tests  6 failed | 77 passed (83)

Those are real-Gateway RPC timeouts in a PTY end-to-end suite. This PR changes two files, both under extensions/qqbot/src/engine/commands/: the /bot-upgrade handler string and its test. There is no path from a QQBot slash-command response to TUI PTY attach or Gateway chat.history / sessions.create RPCs.

The same class of failure is showing up on main right now, so it does not look specific to this branch either:

  • run 30953366239 on main (9bfe292c8): checks-ui-e2e (1/4) failed
  • run 30950415902 on main (8fc445859): checks-node-compact-small-1 failed

Both took openclaw/ci-gate down with them, same as here.

I cannot rerun the job myself (gh run rerun returns "Must have admin rights to Repository"), so I am leaving it rather than pushing a speculative commit to retrigger. A rerun of build-artifacts should be enough; happy to rebase onto a newer main instead if you would rather see a fresh run.

For what it is worth on the parts I can control: node scripts/run-vitest.mjs extensions/qqbot is 86 files / 767 tests green locally, check-extension-package-tsc-boundary.mjs exits 0, and oxlint is clean on both changed files.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Following up on the CI red with the check I had skipped, plus the counter-evidence against my own first read.

The fair counter-signal first: build-artifacts passed on my other two code PRs opened in the same window (#119326 and #119356), so this job is clearly not broken for everyone right now. That is what made me go back and look for a mechanism instead of stopping at "flaky".

The one plausible mechanism was that this PR adds a static import (normalizeOptionalString from openclaw/plugin-sdk/string-coerce-runtime) into a bundled plugin module, which can shift module boundaries and bundling. I had not run a build after that change, which was a gap on my side. I have now:

rm -rf dist && pnpm build   ->   exit 0
INEFFECTIVE_DYNAMIC_IMPORT  ->   0 occurrences
no resolution or bundling errors

The subpath was already in use elsewhere in this plugin (extensions/qqbot/src/exec-approvals.ts:21), so it resolves in the built package.

With that ruled out, what is left points away from this diff:

  • every failure in the job is src/tui/tui-pty-local.e2e.test.ts, "TUI PTY real backends > with shared Gateway fixture", failing as gateway request timeout for chat.history and sessions.create at timeoutMs: 30000, plus one Test timed out in 150000ms
  • the string qqbot appears zero times anywhere in the failing job log
  • there are no Cannot find module, ERR_MODULE, or "does not provide an export" errors in the log
  • the changed surface is a QQBot slash-command response string and its unit test; there is no path from it to TUI PTY attach or Gateway session RPCs

So my read is a flaky real-backend E2E rather than a regression from this change, and the passing runs elsewhere are consistent with intermittency rather than with the job being healthy for every run.

I am not pushing a speculative commit to retrigger, and I cannot rerun it myself (gh run rerun gives "Must have admin rights to Repository"). A rerun of build-artifacts is all I am asking for. If it fails again on an unchanged head I will treat that as a real signal and dig into the TUI path properly rather than repeating this argument.

Local state on the changed surface: extensions/qqbot 86 files / 767 tests green, check-extension-package-tsc-boundary.mjs exit 0, oxlint clean, and now a clean full build.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

build-artifacts is red here, and there is now cross-PR evidence that it is the suite rather than the diff.

The identical failure is happening on two of my open PRs whose diffs have nothing in common:

Both fail the same way, in the same suite:

src/tui/tui-pty-local.e2e.test.ts  "TUI PTY real backends > with shared Gateway fixture"
GatewayClientRequestTimeoutError: gateway request timeout for chat.history
Serialized Error: { method: 'sessions.create', timeoutMs: 30000, requestSent: true }
Error: Test timed out in 150000ms.

There is no single change that is simultaneously in the embedded agent runner and in a QQBot command string, so a shared real-Gateway PTY end-to-end suite timing out on 30s RPCs is the far more likely explanation than either diff.

Supporting detail: the string qqbot appears zero times in the #119357 failing log, there are no Cannot find module / ERR_MODULE / missing-export errors in either log, and a full rm -rf dist && pnpm build is clean on both branches with zero INEFFECTIVE_DYNAMIC_IMPORT warnings.

I am not pushing speculative commits to retrigger, and I cannot rerun jobs myself (gh run rerun returns "Must have admin rights to Repository"). A rerun of build-artifacts on either PR should settle it. If it reproduces on an unchanged head I will stop calling it flaky and go dig into the TUI fixture properly.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Two things: the CI answer you asked for, and stronger proof so this PR is not sitting on unit tests alone.

On build-artifacts. The red check is still pointing at run 30954765875, which is the same run from earlier, on the unchanged head 589212d78d8. No new run had happened, so there was nothing new in the log to diagnose. I have now pushed real proof work (below), which triggers a fresh run rather than a no-op retrigger commit.

My read is unchanged and I will restate it compactly, because it is cross-PR rather than a guess about my own diff:

  • the only failures in that job are src/tui/tui-pty-local.e2e.test.ts, "TUI PTY real backends > with shared Gateway fixture", failing as gateway request timeout for chat.history / sessions.create at timeoutMs: 30000 plus Test timed out in 150000ms
  • the same suite failed identically on fix(agents): honor account-scoped history limits instead of silently ignoring them #119326 (core embedded agent runner) and fix(irc): drop the never-read mentionPatterns config key #119356 (IRC schema and types). No single change spans a QQBot command string, the agent runner, and an IRC schema
  • qqbot appears zero times in the failing log, and there are no module resolution errors
  • I ran that suite locally and it passes 21/21, with per-test durations of 87695ms, 83840ms, and 77887ms against the 150000ms cap. One test using ~58% of the budget on an idle machine is what tips over on a loaded runner

I still cannot rerun jobs myself (gh run rerun returns "Must have admin rights to Repository").

Stronger proof, which is what the review actually asked for. My earlier tests called the command handler through the registry, which proves wiring but not the reply an operator sees. The new test drives /bot-upgrade through trySlashCommand, the plugin's real dispatch seam, with a real account config, and asserts the text actually handed to the sender. Same harness shape as register-group-allways.test.ts.

✓ sends the operator-configured upgrade url to the chat
✓ sends the bundled guide when the key is unset or blank

The first case asserts the configured URL is present and the bundled q.qq.com guide is absent, so a regression that silently ignores the key fails rather than passing on a substring. I confirmed that by forcing configuredUrl to undefined and rerunning: 1 failed | 1 passed, then 2/2 restored.

Full gates on the new head: extensions/qqbot 87 files / 769 tests passing, tsgo -p test/tsconfig/tsconfig.extensions.test.json clean, check-extension-package-tsc-boundary.mjs exit 0, oxlint clean, git diff --check clean, and a clean rm -rf dist && pnpm build with zero INEFFECTIVE_DYNAMIC_IMPORT.

If a redacted live QQBot C2C transcript is still required on top of this, say so and I will arrange one rather than keep substituting harness evidence for it.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 10, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

P3 fixed on 69033a79ae1.

Document the activated QQBot upgradeUrl setting. Fair, and the timing note is fair too: the gap predates this PR, but this PR is what makes the setting actually do something, so it belongs here. docs/channels/qqbot.md now points the /bot-upgrade table row at the setting and adds a short note naming both accepted scopes, channels.qqbot.upgradeUrl and channels.qqbot.accounts.<id>.upgradeUrl, plus what unset means.

I deliberately did not document a root-versus-account precedence order. I verified that upgradeUrl lives on QQBotAccountSchema, which buildMultiAccountChannelSchema places at both scopes, and that the handler reads ctx.accountConfig.upgradeUrl and falls back to the bundled guide constant. What I did not verify is whether account.config is root-merged before it reaches the handler, so rather than assert an ordering I could not demonstrate, the note says the command returns the value configured for the account that received it. If you would like the precedence spelled out, tell me and I will trace the account resolution and document what it actually does.

That restraint is deliberate: earlier in this PR series I described intended rather than observed behavior three times and had to correct it each time.

Validation on 69033a79ae1: node scripts/check-docs-mdx.mjs docs README.md passed across 767 files; oxfmt --check docs/ clean; git diff --check clean. Docs-only change, so no other lanes apply.

The real QQBot C2C delivery proof is still outstanding. I do not have a live QQBot account, so unless a mock-gateway verdict artifact would satisfy it, that one stays open and I am not going to dress up the mocked dispatcher test as something it is not.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 10, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Security P1 fixed on b6c6b61e4bc. You are right, and this was my bug to introduce.

Do not reveal custom guides to unauthorised C2C senders. Confirmed rather than taken on faith: bot-upgrade is registered with c2cOnly: true and no requireAuth (register-basic.ts:89), so it runs for any C2C contact, and the docs in this very PR say so. Substituting an operator-configured upgradeUrl there turns a public guide command into an information disclosure, since that URL can be an internal runbook.

The gate is now ctx.commandAuthorized: authorized senders get the configured guide, everyone else gets the bundled public link. I kept the capability rather than reverting it, since removing a documented setting to close a leak would trade one defect for another, and the context already carries the authorization signal this needs.

The part I want to own explicitly: my own test was demonstrating the leak and I did not notice. createStreamingContext defaults to senderId: "UNTRUSTED_OPENID" and commandAuthorized: false, so the test asserting the configured URL was proving that an unauthorized sender receives it. That is a reminder that a passing test only means what its fixture says, and I read the assertion without reading the fixture.

Tests now cover both dispatch paths, and the deliberate break makes the leak explicit. Removing the gate fails never reveals a configured guide to an unauthorized C2C sender with:

AssertionError: expected '📘 QQBot 升级指引:\n[点击查看升级说明](https://op…' not to contain 'ops.example.com'

Docs updated in the same change, since the previous wording would now be wrong: the note says the configured guide goes only to a sender on the explicit non-wildcard allowlist and that every other C2C sender gets the bundled link.

Validation on b6c6b61e4bc:

  • node scripts/run-vitest.mjs extensions/qqbot — 87 files, 770 passed, with the new unauthorized-path test failing under the break.
  • node scripts/run-tsgo.mjs -p tsconfig.extensions.json exit 0; node scripts/run-oxlint.mjs extensions/qqbot exit 0; oxfmt --check clean.
  • node scripts/check-docs-mdx.mjs docs README.md passed across 767 files; git diff --check clean.

On the outstanding real-behavior proof: I still do not have a live QQBot C2C account, so that one remains genuinely open rather than quietly satisfied. If a mock-gateway verdict artifact would qualify, say so and I will produce one; otherwise this needs someone with a QQBot account.

channels.qqbot.upgradeUrl documents itself as the URL /bot-upgrade returns, but
the handler took no context and always emitted the bundled constant, so the key
validated and did nothing. Read it from ctx.accountConfig with the bundled guide
as fallback.
Drives /bot-upgrade through trySlashCommand with a real account config and
asserts the text sent to the chat, rather than calling the handler directly.
The command table listed /bot-upgrade without telling operators which key
controls the link it returns, so the setting this PR activates was not
discoverable.
/bot-upgrade is deliberately outside the allowlist, so returning the
operator-configured upgradeUrl exposed a potentially private runbook to any C2C
contact. Authorized senders get the configured guide; everyone else keeps the
bundled public link.
@ayaangazali
ayaangazali force-pushed the fix/qqbot-honor-upgrade-url branch from b6c6b61 to fe64c71 Compare August 11, 2026 09:56
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Closing this: main removed the bundled QQBot source, so the file this patches no longer exists in the repo.

refactor(qqbot): install plugin from Tencent package (#107295, commit 84c7d45f15c) deleted extensions/qqbot/** and repointed the catalog at the published package. That commit is 379 files and roughly 47,500 deletions, and extensions/qqbot/src/engine/commands/builtin/register-basic.ts, the file this PR fixes, is gone from main. My rebase surfaced it as delete-versus-modify on both the handler and its test, which is what sent me to look.

There is nothing to salvage by rebasing, since the change has no home here any more.

One thing I would rather not see lost, and it is not the original fix. Beyond honoring upgradeUrl, this branch carried a security fix that came out of review: /bot-upgrade is registered c2cOnly with no requireAuth, so any C2C contact can run it, and returning an operator-configured URL exposed a potentially private runbook. The fix gated the configured guide on ctx.commandAuthorized so unauthorized senders keep the bundled public link, with tests covering both dispatch paths.

If the extracted plugin carried the original behavior across, it very likely carried that hole with it, since it predates my change. Worth a look by whoever owns the Tencent package; I am happy to open it there if you point me at the right repo, and I am not going to file anything speculatively against a package I have not read.

Closing rather than leaving it open, since a PR against deleted files only costs reviewers time. Thanks for the reviews on it, and the authorization finding in particular was a good catch on my own regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: qqbot docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants