mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 09:47:28 +00:00
fix: harden Slack file-only fallback placeholder (#25181) (thanks @justinhuangcode)
This commit is contained in:
@@ -239,6 +239,18 @@ describe("slack prepareSlackMessage inbound contract", () => {
|
||||
expect(prepared!.ctxPayload.RawBody).toContain("photo.jpg");
|
||||
});
|
||||
|
||||
it("falls back to generic file label when a Slack file name is empty", async () => {
|
||||
const prepared = await prepareWithDefaultCtx(
|
||||
createSlackMessage({
|
||||
text: "",
|
||||
files: [{ name: "" }],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(prepared).toBeTruthy();
|
||||
expect(prepared!.ctxPayload.RawBody).toContain("[Slack file: file]");
|
||||
});
|
||||
|
||||
it("keeps channel metadata out of GroupSystemPrompt", async () => {
|
||||
const slackCtx = createInboundSlackCtx({
|
||||
cfg: {
|
||||
|
||||
@@ -371,7 +371,7 @@ export async function prepareSlackMessage(params: {
|
||||
!mediaPlaceholder && (message.files?.length ?? 0) > 0
|
||||
? message
|
||||
.files!.slice(0, MAX_SLACK_MEDIA_FILES)
|
||||
.map((f) => f.name ?? "file")
|
||||
.map((f) => f.name?.trim() || "file")
|
||||
.join(", ")
|
||||
: undefined;
|
||||
const fileOnlyPlaceholder = fileOnlyFallback ? `[Slack file: ${fileOnlyFallback}]` : undefined;
|
||||
|
||||
Reference in New Issue
Block a user