fix: harden Slack file-only fallback placeholder (#25181) (thanks @justinhuangcode)

This commit is contained in:
Peter Steinberger
2026-02-25 05:36:06 +00:00
parent a6337be3d1
commit b247cd6d65
3 changed files with 14 additions and 1 deletions

View File

@@ -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: {

View File

@@ -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;