diff --git a/actions/setup/js/temporary_id.cjs b/actions/setup/js/temporary_id.cjs index cb21069ad54..2bea0a36e99 100644 --- a/actions/setup/js/temporary_id.cjs +++ b/actions/setup/js/temporary_id.cjs @@ -302,7 +302,9 @@ function resolveIssueNumber(value, temporaryIdMap) { // Strip # prefix if present to allow flexible temporary ID format const valueStr = String(value).trim(); - const valueWithoutHash = valueStr.startsWith("#") ? valueStr.substring(1) : valueStr; + // Strip surrounding quotes (agent sometimes double-quotes string values, e.g. `"aw_foo"`) + const unquoted = /^(["'])(.+)\1$/.test(valueStr) ? valueStr.slice(1, -1) : valueStr; + const valueWithoutHash = unquoted.startsWith("#") ? unquoted.substring(1) : unquoted; // Check if it's a temporary ID if (isTemporaryId(valueWithoutHash)) { diff --git a/actions/setup/js/temporary_id.test.cjs b/actions/setup/js/temporary_id.test.cjs index 243a49313e2..f3fe2ac5f90 100644 --- a/actions/setup/js/temporary_id.test.cjs +++ b/actions/setup/js/temporary_id.test.cjs @@ -486,6 +486,42 @@ describe("temporary_id.cjs", () => { expect(result.errorMessage).toContain("Invalid temporary ID format"); expect(result.errorMessage).toContain("#aw_test-id"); }); + + it("should strip surrounding double quotes from temporary ID", async () => { + const { resolveIssueNumber } = await import("./temporary_id.cjs"); + const map = new Map([["aw_blazwasm", { repo: "owner/repo", number: 42 }]]); + const result = resolveIssueNumber('"aw_blazwasm"', map); + expect(result.resolved).toEqual({ repo: "owner/repo", number: 42 }); + expect(result.wasTemporaryId).toBe(true); + expect(result.errorMessage).toBe(null); + }); + + it("should strip surrounding single quotes from temporary ID", async () => { + const { resolveIssueNumber } = await import("./temporary_id.cjs"); + const map = new Map([["aw_foo123", { repo: "owner/repo", number: 7 }]]); + const result = resolveIssueNumber("'aw_foo123'", map); + expect(result.resolved).toEqual({ repo: "owner/repo", number: 7 }); + expect(result.wasTemporaryId).toBe(true); + expect(result.errorMessage).toBe(null); + }); + + it("should strip surrounding double quotes from numeric issue number", async () => { + const { resolveIssueNumber } = await import("./temporary_id.cjs"); + const map = new Map(); + const result = resolveIssueNumber('"789"', map); + expect(result.resolved).toEqual({ repo: "testowner/testrepo", number: 789 }); + expect(result.wasTemporaryId).toBe(false); + expect(result.errorMessage).toBe(null); + }); + + it("should not strip mismatched surrounding quotes from temporary ID", async () => { + const { resolveIssueNumber } = await import("./temporary_id.cjs"); + const map = new Map(); + const result = resolveIssueNumber("\"aw_foo123'", map); + expect(result.resolved).toBe(null); + expect(result.wasTemporaryId).toBe(false); + expect(result.errorMessage).not.toBe(null); + }); }); describe("serializeTemporaryIdMap", () => {