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
4 changes: 3 additions & 1 deletion actions/setup/js/temporary_id.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
36 changes: 36 additions & 0 deletions actions/setup/js/temporary_id.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Loading