fix(line): use getRegistry callback in plugin HTTP handler to prevent stale-route 404#34646
fix(line): use getRegistry callback in plugin HTTP handler to prevent stale-route 404#34646joelnishanth wants to merge 2 commits into
Conversation
… stale-route 404 When a plugin config change triggers loadOpenClawPlugins with a different cache key, setActivePluginRegistry replaces the active registry with a new object. createGatewayPluginRequestHandler was capturing the original registry at startup, so any routes re-registered by channels (e.g. /line/webhook) on the new registry were invisible to the HTTP handler — returning 404 until a full gateway restart. Fix: accept a getRegistry callback instead of a pinned registry reference so the handler always resolves routes from the current active registry. Also update the shouldEnforcePluginGatewayAuth call in server-runtime-state.ts to use requireActivePluginRegistry() inline for the same reason. Adds a regression test (stale-registry swap) that fails without the fix and passes with it. Closes openclaw#34631
Greptile SummaryThis PR fixes a stale-registry bug in the gateway's plugin HTTP handler by replacing the pinned
Confidence Score: 4/5
Last reviewed commit: bc713dd |
Additional Comments (1)
After this change, Leaving it in place risks misleading future maintainers into thinking it still influences the handler's behavior. Consider removing it from the type signature (and the corresponding call-site) in a follow-up, or at minimum adding a |
|
Objective status snapshot:
Actionable next steps:
|
Made-with: Cursor
|
The |
|
Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit. |
|
Reopening. Only PR for issue #34631. CI passing, ready for review. |
Summary
loadOpenClawPluginsis called again with a different cache key, creating a newPluginRegistryand callingsetActivePluginRegistry(newRegistry). The gateway HTTP handler (createGatewayPluginRequestHandler) still holds a reference to the original registry from startup. The LINE channel then re-registers/line/webhookon the new active registry, but all incoming requests are matched against the old (now empty) registry — returning 404 until a full gateway restart.createGatewayPluginRequestHandlernow accepts agetRegistrycallback (() => PluginRegistry) instead of a pinnedregistryobject, and resolves the live registry on every request.shouldEnforceGatewayAuthForPluginPathinserver-runtime-state.tsis updated to callrequireActivePluginRegistry()inline as well.monitorLineProvider,registerPluginHttpRoute, channel lifecycle, auth enforcement behaviour.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
/line/webhook(and any other plugin-registered webhook path) remains reachable after plugin config edits without requiring a gateway restart.Security Impact (required)
Repro + Verification
Environment
Steps
openclaw config set plugins.X.enabled true/false(triggersloadOpenClawPluginswith a new cache key).curl -i http://127.0.0.1:18789/line/webhookExpected
Actual (before fix)
openclaw gateway restartEvidence
Human Verification (required)
loadOpenClawPlugins→setActivePluginRegistry→createGatewayPluginRequestHandlerin code review; confirmed that the capturedregistryreference goes stale on any cache-key change.Compatibility / Migration
Failure Recovery (if this breaks)
src/gateway/server/plugins-http.tsandsrc/gateway/server-runtime-state.tsto the captured-registry pattern.Risks and Mitigations
requireActivePluginRegistry()called on every HTTP request adds a negligible Map-lookup overhead.— Joel Nishanth · offlyn.AI