From 36c44abc872480334302fb64f12779516e26d1cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 05:02:43 +0000 Subject: [PATCH 1/3] Initial plan From cc03161962aacfe031e1e799f4e3833b0b2834bb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 05:09:57 +0000 Subject: [PATCH 2/3] fix: allow up to MAX_LABELS (10) labels for update_discussion The validateLabels call in update_discussion.cjs was not passing maxCount, so it defaulted to 3. Now passes MAX_LABELS (10) to be consistent with the tryEnforceArrayLimit check above it. Fixes: Discussion labels limited to 3 per item Agent-Logs-Url: https://github.com/github/gh-aw/sessions/11bde075-8540-40c3-955b-2bc46c63e5b5 Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- actions/setup/js/update_discussion.cjs | 2 +- actions/setup/js/update_discussion.test.cjs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/actions/setup/js/update_discussion.cjs b/actions/setup/js/update_discussion.cjs index 01ad842c415..5a0d63a1161 100644 --- a/actions/setup/js/update_discussion.cjs +++ b/actions/setup/js/update_discussion.cjs @@ -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" }; } diff --git a/actions/setup/js/update_discussion.test.cjs b/actions/setup/js/update_discussion.test.cjs index 9e7357ca697..cab6424b238 100644 --- a/actions/setup/js/update_discussion.test.cjs +++ b/actions/setup/js/update_discussion.test.cjs @@ -36,6 +36,8 @@ 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_kwDO_bug", name: "bug" }, { id: "LA_kwDO_feature", name: "feature" }, ]; @@ -282,6 +284,25 @@ 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"]); + }); }); describe("title-only update", () => { From e2900ea8e1800b483f61207e775511bf5dfbd145 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 05:32:55 +0000 Subject: [PATCH 3/3] test: add test case for more than MAX_LABELS (10) in update_discussion Agent-Logs-Url: https://github.com/github/gh-aw/sessions/cef10ec6-e0ed-4975-a99c-e518e1bf693d Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> --- actions/setup/js/update_discussion.test.cjs | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/actions/setup/js/update_discussion.test.cjs b/actions/setup/js/update_discussion.test.cjs index cab6424b238..69770dad0b3 100644 --- a/actions/setup/js/update_discussion.test.cjs +++ b/actions/setup/js/update_discussion.test.cjs @@ -38,6 +38,11 @@ describe("update_discussion", () => { { 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" }, ]; @@ -303,6 +308,31 @@ describe("update_discussion", () => { 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", () => {