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
2 changes: 1 addition & 1 deletion actions/setup/js/update_discussion.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function buildDiscussionUpdateData(item, config) {
}

const allowedLabels = config.allowed_labels || [];
const labelsResult = validateLabels(item.labels, allowedLabels.length > 0 ? allowedLabels : undefined);
const labelsResult = validateLabels(item.labels, allowedLabels.length > 0 ? allowedLabels : undefined, MAX_LABELS);
if (!labelsResult.valid) {
return { success: false, error: labelsResult.error ?? "Invalid labels" };
}
Expand Down
51 changes: 51 additions & 0 deletions actions/setup/js/update_discussion.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ describe("update_discussion", () => {
{ id: "LA_kwDO2", name: "Label2" },
{ id: "LA_kwDO3", name: "Label3" },
{ id: "LA_kwDO4", name: "Label4" },
{ id: "LA_kwDO5", name: "Label5" },
{ id: "LA_kwDO6", name: "Label6" },
{ id: "LA_kwDO7", name: "Label7" },
{ id: "LA_kwDO8", name: "Label8" },
{ id: "LA_kwDO9", name: "Label9" },
{ id: "LA_kwDO10", name: "Label10" },
{ id: "LA_kwDO11", name: "Label11" },
{ id: "LA_kwDO_bug", name: "bug" },
{ id: "LA_kwDO_feature", name: "feature" },
];
Expand Down Expand Up @@ -282,6 +289,50 @@ describe("update_discussion", () => {
// Label1 has id "LA_kwDO1"
expect(addCalls[0].variables.labelIds).toEqual(["LA_kwDO1"]);
});

it("should allow up to MAX_LABELS (10) labels, not just 3 (issue: discussion labels limited to 3 per item)", async () => {
const handler = await main({
target: "*",
allow_labels: true,
});

// Agent requests 5 labels - previously this would truncate to 3
const result = await handler({ type: "update_discussion", labels: ["Label1", "Label2", "Label3", "Label4", "Label5"], discussion_number: 42 }, {});
expect(result.success).toBe(true);

// Must not call updateDiscussion mutation (labels-only update)
expect(getUpdateDiscussionMutations()).toHaveLength(0);

// All 5 labels should be applied, not truncated to 3
const addCalls = getAddLabelsCalls();
expect(addCalls).toHaveLength(1);
expect(addCalls[0].variables.labelIds).toEqual(["LA_kwDO1", "LA_kwDO2", "LA_kwDO3", "LA_kwDO4", "LA_kwDO5"]);
});

it("should reject when more than MAX_LABELS (10) labels are requested", async () => {
const handler = await main({
target: "*",
allow_labels: true,
});

// Agent requests 11 labels — exceeds MAX_LABELS limit
const result = await handler(
{
type: "update_discussion",
labels: ["Label1", "Label2", "Label3", "Label4", "Label5", "Label6", "Label7", "Label8", "Label9", "Label10", "Label11"],
discussion_number: 42,
},
{}
);

expect(result.success).toBe(false);
expect(result.error).toContain("E003");
expect(result.error).toContain("10");

// No label mutations should have been called
expect(getAddLabelsCalls()).toHaveLength(0);
expect(getRemoveLabelsCalls()).toHaveLength(0);
});
});

describe("title-only update", () => {
Expand Down
Loading