Skip to content

fix(gateway): claim malformed plugin icon routes - #119559

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
sunlit-deng:sunlit/fix/local-candidate-plugin-icon-route-claim
Aug 5, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
sunlit-deng:sunlit/fix/local-candidate-plugin-icon-route-claim

Conversation

@sunlit-deng

@sunlit-deng sunlit-deng commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where malformed plugin and catalog icon URLs could fall through to the Control UI and return the SPA HTML with a 200 response.

Why This Change Was Made

Icon route parsing now distinguishes an unrelated path from a matched route with invalid input, while preserving the existing method and authentication checks. Both icon route variants use the same closed parser state, following the route-ownership pattern established by #85261.

User Impact

Malformed icon URLs now receive the route-owned 404 Not Found response instead of the Control UI HTML.

Evidence

  • pnpm test src/gateway/plugin-icon-http.test.ts: 32 focused tests passed.
  • pnpm exec tsx proof-live.ts: the same loopback HTTP call chain ran the production icon handler followed by the production Control UI handler on the pinned base and exact head.
$ pnpm exec tsx proof-live.ts
base 26a58bcd92baeb8ed6595d5202b16bd4e08be704
malformed-plugin=200 owner=control-ui
malformed-catalog=200 owner=control-ui
negative-control=200 owner=control-ui

head 8bd8703d75af93a0ede3ffcc8bd7dfb474142705
malformed-plugin=404 owner=Not Found
malformed-catalog=404 owner=Not Found
negative-control=200 owner=control-ui
proof-live.ts
import { execFileSync } from "node:child_process";
import { mkdtemp, rm, writeFile } from "node:fs/promises";
import { createServer } from "node:http";
import { tmpdir } from "node:os";
import { join } from "node:path";

const uiRoot = await mkdtemp(join(tmpdir(), "openclaw-icon-route-proof-"));
await writeFile(join(uiRoot, "index.html"), "<!doctype html><title>control-ui-fallback</title>");
await writeFile(join(uiRoot, "openclaw.json"), "{}\n");
process.env.OPENCLAW_CONFIG_PATH = join(uiRoot, "openclaw.json");
process.env.OPENCLAW_STATE_DIR = uiRoot;

const { handleControlUiHttpRequest } = await import("./src/gateway/control-ui.ts");
const { handlePluginIconHttpRequest } = await import("./src/gateway/plugin-icon-http.ts");

const server = createServer(async (req, res) => {
  try {
    const handled = await handlePluginIconHttpRequest(req, res, {
      auth: { mode: "none" },
      config: {},
    });
    if (!handled) {
      await handleControlUiHttpRequest(req, res, {
        auth: { mode: "none" },
        config: {},
        root: { kind: "resolved", path: uiRoot },
      });
    }
  } catch (error) {
    res.statusCode = 500;
    res.end(error instanceof Error ? error.message : String(error));
  }
});

await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
const address = server.address();
if (!address || typeof address === "string") {
  throw new Error("loopback server did not expose a TCP address");
}

async function request(path: string): Promise<{ status: number; owner: string }> {
  const response = await fetch(`http://127.0.0.1:${address.port}${path}`);
  const body = await response.text();
  return {
    status: response.status,
    owner: body.includes("control-ui-fallback") ? "control-ui" : body,
  };
}

try {
  const sha = execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }).trim();
  const plugin = await request("/__openclaw__/plugin-icon/%zz");
  const catalog = await request("/__openclaw__/catalog-icon/%zz");
  const negativeControl = await request("/settings");
  console.log(`sha=${sha}`);
  console.log(`malformed-plugin=${plugin.status} owner=${plugin.owner}`);
  console.log(`malformed-catalog=${catalog.status} owner=${catalog.owner}`);
  console.log(`negative-control=${negativeControl.status} owner=${negativeControl.owner}`);
  if (
    !([200, 404].includes(plugin.status) && [200, 404].includes(catalog.status)) ||
    negativeControl.status !== 200 ||
    negativeControl.owner !== "control-ui"
  ) {
    process.exitCode = 1;
  }
} finally {
  await new Promise<void>((resolve, reject) =>
    server.close((error) => (error ? reject(error) : resolve())),
  );
  await rm(uiRoot, { recursive: true, force: true });
}

AI-assisted: built with Codex

Punchcard-Session: clear-orchard-lantern-bc

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Aug 5, 2026
@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. 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, 9:19 AM ET / 13:19 UTC.

ClawSweeper review

What this changes

The PR makes malformed plugin and catalog icon URLs return their route-owned 404 response instead of falling through to the Control UI SPA.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open: current main still conflates a malformed reserved icon route with an unrelated route, and the proposed parser-level ownership fix correctly prevents Control UI SPA fallback without changing valid icon handling.

Priority: P2
Reviewed head: 8bd8703d75af93a0ede3ffcc8bd7dfb474142705

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, owner-boundary repair with exact-head behavioral proof, targeted regression coverage, and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body and subsequent maintainer validation provide exact-head production-handler loopback output showing the malformed-route 404 while preserving Control UI fallback for an unrelated path.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body and subsequent maintainer validation provide exact-head production-handler loopback output showing the malformed-route 404 while preserving Control UI fallback for an unrelated path.
Evidence reviewed 6 items Current-main failure mechanism: Current main still returns null for both malformed reserved paths and unrelated paths, then reports the request unhandled when both parser results are null; the icon request can therefore continue to Control UI fallback.
Gateway dispatch order: The icon stage runs for both reserved prefixes before the Control UI HTTP stage, so a matched malformed path must be claimed by the icon handler rather than repaired in the generic UI fallback.
Exact-head repair and coverage: The proposed closed parser result distinguishes unmatched from matched-invalid paths; table-driven tests cover blank, invalid, malformed, and nested plugin/catalog paths and assert 404 without metadata resolution or remote fetching.
Findings None None.
Security None None.

How this fits together

Gateway request stages send reserved plugin and catalog icon paths to the icon handler before the Control UI fallback. The handler authenticates and resolves valid icons, while malformed paths should end with the icon endpoint’s own response.

flowchart LR
  A[Browser icon URL] --> B[Gateway request stages]
  B --> C[Icon route parser]
  C -->|Unrelated path| D[Control UI fallback]
  C -->|Reserved malformed path| E[Owned 404 response]
  C -->|Reserved valid path| F[Authentication and icon resolver]
  F --> G[Validated icon response]
Loading

Before merge

  • Complete next step (P2) - No repair job is needed because this open PR already contains the narrow, reviewed fix; it should proceed through normal maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +4, Tests +23. Total +27 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 34 30 +4
Tests 1 23 0 +23
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 57 30 +27

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +4 net, tests +23 The small production increase establishes an explicit route-ownership boundary and is paired with focused malformed-path coverage.

Technical review

Best possible solution:

Land the parser-boundary repair after the normal exact-head merge gate so malformed reserved icon routes retain ownership and unrelated paths continue to reach the Control UI.

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

Yes, with high confidence from source and the supplied production-handler loopback transcript: current main retains the nullable parser and the pre-fallback dispatch order, while the exact head returns 404 for the same malformed URLs.

Is this the best way to solve the issue?

Yes. Recording matched-versus-invalid state at the icon parser is the narrowest canonical fix; changing Gateway stage order or Control UI fallback would duplicate endpoint policy and affect unrelated paths.

AGENTS.md: found and applied where relevant.

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

Labels

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: Malformed icon routes currently receive an incorrect Control UI success response, but the defect is narrowly limited to reserved Gateway icon URLs.
  • 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 (terminal): The PR body and subsequent maintainer validation provide exact-head production-handler loopback output showing the malformed-route 404 while preserving Control UI fallback for an unrelated path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and subsequent maintainer validation provide exact-head production-handler loopback output showing the malformed-route 404 while preserving Control UI fallback for an unrelated path.

Evidence

What I checked:

  • Current-main failure mechanism: Current main still returns null for both malformed reserved paths and unrelated paths, then reports the request unhandled when both parser results are null; the icon request can therefore continue to Control UI fallback. (src/gateway/plugin-icon-http.ts:264, d85920c03e25)
  • Gateway dispatch order: The icon stage runs for both reserved prefixes before the Control UI HTTP stage, so a matched malformed path must be claimed by the icon handler rather than repaired in the generic UI fallback. (src/gateway/server-http.ts:700, d85920c03e25)
  • Exact-head repair and coverage: The proposed closed parser result distinguishes unmatched from matched-invalid paths; table-driven tests cover blank, invalid, malformed, and nested plugin/catalog paths and assert 404 without metadata resolution or remote fetching. (src/gateway/plugin-icon-http.ts:69, 8bd8703d75af)
  • Sibling owner-boundary precedent: The merged session-history repair uses the same tagged matched-versus-invalid route result and returns an endpoint-owned error instead of falling through, supporting the parser-boundary fix shape. (src/gateway/sessions-history-http.ts:50, 7617e91d700c)
  • Real behavior and exact-head validation: The PR body shows a production-handler loopback before/after result (malformed paths change from Control UI 200 to icon-owned 404 while /settings remains Control UI 200); the maintainer’s exact-head comment records focused 32/32 tests, strict loopback coverage, and terminal hosted CI. (8bd8703d75af)
  • Feature provenance: Blame ties the nullable parser and unhandled return on current main to the original icon-route implementation commit, which is the reviewed source change that made the fallback visible. (src/gateway/plugin-icon-http.ts:264, 4b7a989a8bfe)

Likely related people:

  • Jason (Json): Current-main blame attributes the nullable icon parsers and unhandled return to the commit that introduced this handler. (role: original icon-route implementation author; confidence: high; commits: 4b7a989a8bfe; files: src/gateway/plugin-icon-http.ts, src/gateway/plugin-icon-http.test.ts)
  • cropsgg: Authored the merged session-history repair that established the matching tagged route-resolution pattern in an adjacent Gateway handler. (role: sibling route-owner-pattern author; confidence: medium; commits: 7617e91d700c; files: src/gateway/sessions-history-http.ts)
  • vincentkoc: Posted the maintainer validation for this head, including focused tests, loopback behavior proof, and hosted CI completion. (role: exact-head validator; confidence: high; files: src/gateway/plugin-icon-http.ts, src/gateway/plugin-icon-http.test.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 (1 earlier review cycle)
  • reviewed 2026-08-05T09:12:54.512Z sha 8bd8703 :: needs maintainer review before merge. :: none

@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@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

Maintainer validation is complete at exact head 8bd8703d75af93a0ede3ffcc8bd7dfb474142705.

  • Root cause: the icon parsers used the same null result for unrelated paths and malformed reserved paths, so the latter could fall through to the Control UI SPA.
  • Best fix: the tagged matched/unmatched parser result records route ownership at the parser boundary while preserving valid icon, authentication, and method behavior.
  • Production delta: +34/-30 (net +4); tests +23/-0.
  • pnpm test src/gateway/plugin-icon-http.test.ts: 32/32 passed on Blacksmith Testbox (run).
  • Strict production-handler loopback: plugin and catalog blank, %20, %zz, and nested paths each returned exact 404 Not Found; /settings remained 200 Control UI (run).
  • Exact-commit autoreview: clean, no accepted/actionable findings.
  • Hosted exact-head CI: terminal green.
  • Native scripts/pr prepare-run 119559 completed with hosted exact-head gates.

@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 Aug 5, 2026
@vincentkoc
vincentkoc merged commit 29175dd into openclaw:main Aug 5, 2026
141 of 149 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 5, 2026
* origin/main: (130 commits)
  refactor(qa): consolidate scenario runtime helpers (openclaw#119623)
  fix(telegram): bind Mini App auth to dashboard launches
  refactor(agent-core): unify session projection and compaction summaries (openclaw#119639)
  fix(codex): allow natural reactions in the current conversation (openclaw#119649)
  refactor(providers): deduplicate bundled model catalogs (openclaw#119627)
  fix(ui): observe the active service worker after asset refresh (openclaw#119622)
  fix(agents): strip echoed base64 image payloads so photo-heavy turns no longer hit the per-turn output cap (openclaw#119488)
  improve: make state-heavy test suites faster (openclaw#119617)
  perf(agents): add concurrency benchmark (openclaw#119569)
  fix(browser): visibly report failed pairing and tab-sharing actions (openclaw#119526)
  refactor(lobster): consolidate embedded workflow execution (openclaw#119630)
  fix(plugin-sdk): stabilize tuple-derived API baseline ordering (openclaw#119635)
  docs(skills): make full-authority maintainer runs unattended (openclaw#119629)
  fix(managed-child): honor process groups that vanish before cleanup (openclaw#119614)
  fix(ci): stop label-driven automation churn (openclaw#119610)
  fix(media): keep the ttl sweep out of the managed outgoing tree (openclaw#119127)
  fix(claws): remove owner-qualified skills (openclaw#119606)
  fix(clawrouter): show stable error for malformed usage responses (openclaw#119580)
  fix(gateway): claim malformed plugin icon routes (openclaw#119559)
  fix(telegram): preserve truthful empty-content delivery (openclaw#88810)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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