← Back to PRs

#16194: fix: route exec approvals to explicit targets regardless of sessionFilter

by MisterGuy420 open 2026-02-14 12:59 View on GitHub →
stale size: M trusted-contributor
## Summary This PR fixes a bug where exec approval requests were not being forwarded to Telegram (or other explicit targets) when `sessionFilter` was configured but did not match the originating session key. The `sessionFilter` configuration was incorrectly blocking ALL forwarding when the session key didn't match, even when explicit targets were configured with `mode: "targets"` or `mode: "both"`. This fix separates the concerns: - `sessionFilter` now only affects session-based forwarding (mode: `"session"` or `"both"`) - Explicit targets (mode: `"targets"` or `"both"`) are always used regardless of `sessionFilter` - `agentFilter` still applies to all modes as intended ## Changes - Modified `shouldForward()` to remove the `sessionFilter` check (it was blocking all forwarding unnecessarily) - Added new `sessionMatchesFilter()` helper function - Updated `handleRequested()` to check `sessionMatchesFilter()` only when resolving session targets - Added 5 new test cases covering the sessionFilter behavior ## Testing - All existing tests pass (5 original tests + 5 new tests = 10 total in exec-approval-forwarder.test.ts) - Related tests in exec-approvals.test.ts and exec-approval.test.ts also pass ## Configuration Example With this fix, the following configuration will now work correctly: ```json { "approvals": { "exec": { "enabled": true, "mode": "targets", "targets": [{ "channel": "telegram", "to": "@user" }] } } } ``` Previously, if `sessionFilter` was set (even to a different value), explicit targets would be ignored. Fixes openclaw/openclaw#16184 <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes a bug where `sessionFilter` in exec approval forwarding config was incorrectly blocking ALL forwarding (including explicit targets) when the session key didn't match. The fix separates `sessionFilter` from the global `shouldForward` gate and moves it to only gate session-based target resolution, so explicit targets (`mode: "targets"` or `mode: "both"`) are always forwarded regardless of `sessionFilter`. - Extracted `sessionMatchesFilter()` helper from `shouldForward()` to isolate session-specific filtering logic - Applied `sessionMatchesFilter()` only in the `mode === "session" || mode === "both"` branch of `handleRequested()` - `agentFilter` continues to apply globally to all forwarding modes, consistent with prior behavior - Added 5 new test cases covering all mode/filter combinations - Note: the exported `shouldForwardExecApproval()` function no longer checks `sessionFilter`, though it has no current external callers <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it fixes a clear bug with clean logic separation and thorough test coverage. - The change is well-scoped, correctly separates sessionFilter from global forwarding, and maintains backward compatibility. The 5 new tests cover all key mode/filter combinations. The only minor concern is that the exported shouldForwardExecApproval now has different semantics (no longer checks sessionFilter), but it has no current external callers. The core logic refactoring is straightforward and easy to verify. - No files require special attention. The changes in `src/infra/exec-approval-forwarder.ts` are clean and well-tested. <sub>Last reviewed commit: 9ed2b8e</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs