fix: validate slack read limits · openclaw/openclaw@c3ff31e
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -876,6 +876,26 @@ describe("handleSlackAction", () => {
|
876 | 876 | }); |
877 | 877 | }); |
878 | 878 | |
| 879 | +it("parses string readMessages limits before reading Slack messages", async () => { |
| 880 | +readSlackMessages.mockResolvedValueOnce({ messages: [], hasMore: false }); |
| 881 | + |
| 882 | +await handleSlackAction( |
| 883 | +{ action: "readMessages", channelId: "C1", limit: "20" }, |
| 884 | +slackConfig(), |
| 885 | +); |
| 886 | + |
| 887 | +expectRecordFields(requireRecordArg(readSlackMessages, "readSlackMessages", 0, 1), { |
| 888 | +limit: 20, |
| 889 | +}); |
| 890 | +}); |
| 891 | + |
| 892 | +it("rejects fractional readMessages limits before reading Slack messages", async () => { |
| 893 | +await expect( |
| 894 | +handleSlackAction({ action: "readMessages", channelId: "C1", limit: 2.5 }, slackConfig()), |
| 895 | +).rejects.toThrow("limit must be a positive integer."); |
| 896 | +expect(readSlackMessages).not.toHaveBeenCalled(); |
| 897 | +}); |
| 898 | + |
879 | 899 | it("reads from allowlisted Slack target channels", async () => { |
880 | 900 | readSlackMessages.mockResolvedValueOnce({ messages: [], hasMore: false }); |
881 | 901 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。