mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 08:52:12 +00:00
Slack: fail oversized merged block payloads
This commit is contained in:
@@ -144,4 +144,27 @@ describe("slackOutbound sendPayload", () => {
|
||||
);
|
||||
expect(result).toMatchObject({ channel: "slack", messageId: "sl-controls" });
|
||||
});
|
||||
|
||||
it("fails when merged Slack blocks exceed the platform limit", async () => {
|
||||
const { run, sendMock } = createHarness({
|
||||
payload: {
|
||||
channelData: {
|
||||
slack: {
|
||||
blocks: Array.from({ length: 50 }, () => ({ type: "divider" })),
|
||||
},
|
||||
},
|
||||
interactive: {
|
||||
blocks: [
|
||||
{
|
||||
type: "buttons",
|
||||
buttons: [{ label: "Allow", value: "pluginbind:approval-123:o" }],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await expect(run()).rejects.toThrow(/Slack blocks cannot exceed 50 items/i);
|
||||
expect(sendMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -139,7 +139,9 @@ function resolveSlackBlocks(payload: {
|
||||
return undefined;
|
||||
}
|
||||
if (mergedBlocks.length > SLACK_MAX_BLOCKS) {
|
||||
return existingBlocks?.length ? existingBlocks : undefined;
|
||||
throw new Error(
|
||||
`Slack blocks cannot exceed ${SLACK_MAX_BLOCKS} items after interactive render`,
|
||||
);
|
||||
}
|
||||
return mergedBlocks;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user