Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions server/src/channels/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ export function parseActivityInput(
if (object.agentId !== null && typeof object.agentId !== "string") {
return { ok: false, error: "Agent ID must be a string or null." };
}
if (
typeof object.agentId === "string" &&
object.agentId.trim().length === 0
) {
return { ok: false, error: "Agent ID must be a string or null." };
}
if (typeof object.at !== "string") {
return { ok: false, error: "Timestamp is required." };
}
Expand Down
13 changes: 13 additions & 0 deletions server/tests/channel-activity-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ describe("parsing a reported message", () => {
expect(parsed.value.text).toBe("hello");
expect(parsed.value.agentId).toBe("agent-1");
});

test("refuses a whitespace-only agent ID rather than looking it up", () => {
// " " used to trim to "" and fall through to a 404 "Agent not found";
// a malformed field is a 400 naming the field.
const parsed = parseActivityInput(
{ text: "hello", agentId: " ", at: "2026-09-03T09:00:00.000Z" },
now,
);
expect(parsed).toEqual({
ok: false,
error: "Agent ID must be a string or null.",
});
});
});