fix: carry forward httpRoutes when plugin registry is replaced#45568
fix: carry forward httpRoutes when plugin registry is replaced#45568masatohoshino wants to merge 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes webhook 404s by carrying forward Key points:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/plugins/runtime.test.ts
Line: 13-47
Comment:
**Tests share mutable global state across cases**
All three test cases operate against the same `globalThis[Symbol.for("openclaw.pluginRegistryState")]` object, because `setActivePluginRegistry` / `getActivePluginRegistry` read and write from that singleton. The tests happen to pass in the current execution order, but any future re-ordering, parallelism, or new test cases inserted between existing ones could produce unexpected failures because the active registry at the start of each `it` block is whatever was left by the previous one.
Add a `beforeEach` (or `afterEach`) that resets the shared state, for example:
```suggestion
import { describe, it, expect, beforeEach } from "vitest";
import { createEmptyPluginRegistry } from "./registry.js";
import type { PluginHttpRouteRegistration } from "./registry.js";
import { setActivePluginRegistry, getActivePluginRegistry } from "./runtime.js";
const makeRoute = (path: string): PluginHttpRouteRegistration => ({
path,
handler: () => {},
auth: "gateway",
match: "exact",
});
describe("setActivePluginRegistry", () => {
beforeEach(() => {
// Reset the global registry state so each test starts from a clean slate
setActivePluginRegistry(createEmptyPluginRegistry());
});
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: cbd5ccc |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbd5cccd60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Extends the httpRoutes carry-forward from PR openclaw#45568 to also preserve channel registrations when the plugin registry is replaced at runtime. Without this, loadOpenClawPlugins() calls triggered by config lookups, schema validation, or maybeBootstrapChannelPlugin() create a new empty registry, causing the message tool to fail with 'Unknown channel' errors because listPluginChannelIds() reads from the now-empty channels array. Co-authored-by: Claude <[email protected]>
When setActivePluginRegistry swaps in a new registry, dynamically registered httpRoutes (from LINE, Google Chat, etc.) were lost because the new registry has an empty httpRoutes array. Now carries forward previous httpRoutes when the new registry has none, preventing webhook 404s after runtime registry swaps. Ref openclaw#45445
- Use prev.httpRoutes reference directly instead of [...spread] to preserve unregister callback identity (Codex P1 feedback) - Add beforeEach to reset global registry state between tests (Greptile feedback)
11e5507 to
ca87dfd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca87dfd7eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Implemented follow-up for Codex P2 (“Restrict route carry-forward to same registry cache key”) in What changed
Validation
I also observed current CI failures in paths outside this PR diff; if they persist after rerun, I can post a per-job non-causality summary. |
|
CI finished, and I checked the failing jobs against this PR diff. This PR only changes:
Current failures are in unrelated paths, for example:
So these failures appear non-causal to this PR’s changes. |
|
CI failures on this PR still appear non-causal to this diff. Could a maintainer please re-run only the failing jobs from run https://github.com/openclaw/openclaw/actions/runs/23195583617 ? Requested re-run targets:
I will not add unrelated "main CI test-fix" commits in this PR, per repo policy ( |
|
Before merge, here is the bug-fix gate checklist from AGENTS.md for this PR:
Merge-policy note: this PR intentionally avoids unrelated CI-only test-fix commits and keeps scope to the runtime registry bug path. |
|
Closing this PR because the issue has been resolved upstream. This was part of the investigation and an alternative fix approach. |
Summary
Fixes webhook 404s caused by httpRoutes being lost when
setActivePluginRegistryreplaces the active registry at runtime.Ref #45445
Root cause
When
loadOpenClawPluginsis called at runtime (config schema lookups, channel status probes, etc.), it creates a fresh registry with an emptyhttpRoutesarray and sets it as active. Webhook routes registered by channel plugins (LINE, Google Chat, etc.) on the previous registry are lost, causing 404s.What changed
setActivePluginRegistryinsrc/plugins/runtime.tsnow carries forwardhttpRoutesfrom the previous registry when the new registry has an emptyhttpRoutesarray.Tests added
Relationship to other PRs