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
33 changes: 33 additions & 0 deletions apps/api/src/tools/task-board/automations.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, expect, it } from "bun:test";
import { TASK_BOARD_AUTOMATION_UPSERT } from "./automations";

/**
* Regression: `prompt` had no length cap — an unbounded `text` column,
* writable directly by any org member's tool call. Same gap as the task
* description cap (#6574's sibling), just on the automation's instruction.
*/
describe("TASK_BOARD_AUTOMATION_UPSERT prompt length", () => {
it("rejects a prompt over the cap", () => {
const result = TASK_BOARD_AUTOMATION_UPSERT.inputSchema.safeParse({
columnKey: "todo",
prompt: "x".repeat(50_001),
});
expect(result.success).toBe(false);
});

it("accepts a prompt at the cap", () => {
const result = TASK_BOARD_AUTOMATION_UPSERT.inputSchema.safeParse({
columnKey: "todo",
prompt: "x".repeat(50_000),
});
expect(result.success).toBe(true);
});

it("accepts a null prompt (the default instruction)", () => {
const result = TASK_BOARD_AUTOMATION_UPSERT.inputSchema.safeParse({
columnKey: "todo",
prompt: null,
});
expect(result.success).toBe(true);
});
});
2 changes: 2 additions & 0 deletions apps/api/src/tools/task-board/automations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from "zod";
import { defineTool } from "@/core/define-tool";
import { requireAuth } from "@/core/studio-context";
import { boardHandler } from "./board-handler";
import { MAX_AUTOMATION_PROMPT_LENGTH } from "./schema";

const AutomationSchema = z.object({
columnKey: z.string(),
Expand Down Expand Up @@ -46,6 +47,7 @@ export const TASK_BOARD_AUTOMATION_UPSERT = defineTool({
.describe("A column of this board — see TASK_BOARD_ITEM_LIST."),
prompt: z
.string()
.max(MAX_AUTOMATION_PROMPT_LENGTH)
.nullable()
.optional()
.describe("What to do with a card landing here; null for the default."),
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/tools/task-board/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const MAX_TASK_TITLE_LENGTH = 500;
* so nothing legitimate approaches this; same reasoning as the caps above. */
export const MAX_TASK_REPO_LENGTH = 200;

/** A column automation's prompt is an instruction, not the message body —
* same reasoning as MAX_TASK_DESCRIPTION_LENGTH. */
export const MAX_AUTOMATION_PROMPT_LENGTH = 50_000;

export const TaskBoardItemStatusSchema = z.enum([
"triage",
"todo",
Expand Down
Loading