Skip to content

Commit 53bcf76

Browse files
Copilotpelikhan
andcommitted
fix: update all error messages and tests from 3-to-8 to 3-to-12 char limit
- Update "3 to 8" → "3 to 12" in error messages across: temporary_id.cjs, create_issue.cjs, create_pull_request.cjs, safe_output_unified_handler_manager.cjs, update_project.cjs - Update test assertions in temporary_id.test.cjs and update_project.test.cjs - Use 13-char "aw_toolong123456" in update_project.test.cjs "too long" test case (previous "aw_toolong123" was 10 chars, now valid under 12-char limit) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 89d3deb commit 53bcf76

7 files changed

Lines changed: 15 additions & 15 deletions

actions/setup/js/create_issue.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ async function main(config = {}) {
340340
} else {
341341
// Check if it looks like a malformed temporary ID
342342
if (parentWithoutHash.startsWith("aw_")) {
343-
core.warning(`Invalid temporary ID format for parent: '${message.parent}'. Temporary IDs must be in format 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`);
343+
core.warning(`Invalid temporary ID format for parent: '${message.parent}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`);
344344
} else {
345345
// It's a real issue number
346346
const parsed = parseInt(parentWithoutHash, 10);

actions/setup/js/create_pull_request.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ async function main(config = {}) {
211211

212212
if (!isTemporaryId(normalized)) {
213213
core.warning(
214-
`Skipping create_pull_request: Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`
214+
`Skipping create_pull_request: Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`
215215
);
216216
return {
217217
success: false,
218-
error: `Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`,
218+
error: `Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`,
219219
};
220220
}
221221

actions/setup/js/safe_output_unified_handler_manager.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ function normalizeAndValidateTemporaryId(message, messageType, messageIndex) {
759759
const withoutHash = trimmed.startsWith("#") ? trimmed.substring(1).trim() : trimmed;
760760

761761
if (!isTemporaryId(withoutHash)) {
762-
throw new Error(`${ERR_VALIDATION}: Message ${messageIndex + 1} (${messageType}): invalid temporary_id '${raw}'. Temporary IDs must be 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9), e.g. 'aw_abc' or 'aw_Test123'`);
762+
throw new Error(`${ERR_VALIDATION}: Message ${messageIndex + 1} (${messageType}): invalid temporary_id '${raw}'. Temporary IDs must be 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9), e.g. 'aw_abc' or 'aw_Test123'`);
763763
}
764764

765765
// Normalize to the strict bare ID to keep lookups consistent.

actions/setup/js/temporary_id.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function replaceTemporaryIdReferences(text, tempIdMap, currentRepo) {
9292
while ((candidate = TEMPORARY_ID_CANDIDATE_PATTERN.exec(text)) !== null) {
9393
const tempId = `aw_${candidate[1]}`;
9494
if (!isTemporaryId(tempId)) {
95-
core.warning(`Malformed temporary ID reference '${candidate[0]}' found in body text. Temporary IDs must be in format '#aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: '#aw_abc' or '#aw_Test123'`);
95+
core.warning(`Malformed temporary ID reference '${candidate[0]}' found in body text. Temporary IDs must be in format '#aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: '#aw_abc' or '#aw_Test123'`);
9696
}
9797
}
9898

@@ -162,7 +162,7 @@ function getOrGenerateTemporaryId(message, entityType = "item") {
162162
if (!isTemporaryId(normalized)) {
163163
return {
164164
temporaryId: null,
165-
error: `Invalid temporary_id format: '${message.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`,
165+
error: `Invalid temporary_id format: '${message.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_Test123'`,
166166
};
167167
}
168168

@@ -298,14 +298,14 @@ function resolveIssueNumber(value, temporaryIdMap) {
298298
return {
299299
resolved: null,
300300
wasTemporaryId: false,
301-
errorMessage: `Invalid temporary ID format: '${valueStr}'. Temporary IDs must be in format 'aw_' followed by 3 to 8 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_abc12345'`,
301+
errorMessage: `Invalid temporary ID format: '${valueStr}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric characters (A-Za-z0-9). Example: 'aw_abc' or 'aw_abc12345'`,
302302
};
303303
}
304304

305305
// It's a real issue number - use context repo as default
306306
const issueNumber = typeof value === "number" ? value : parseInt(valueWithoutHash, 10);
307307
if (isNaN(issueNumber) || issueNumber <= 0) {
308-
return { resolved: null, wasTemporaryId: false, errorMessage: `Invalid issue number: ${value}. Expected either a valid temporary ID (format: aw_ followed by 3-8 alphanumeric characters) or a numeric issue number.` };
308+
return { resolved: null, wasTemporaryId: false, errorMessage: `Invalid issue number: ${value}. Expected either a valid temporary ID (format: aw_ followed by 3-12 alphanumeric characters) or a numeric issue number.` };
309309
}
310310

311311
const contextRepo = typeof context !== "undefined" ? `${context.repo.owner}/${context.repo.repo}` : "";

actions/setup/js/temporary_id.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe("temporary_id.cjs", () => {
323323
expect(result.wasTemporaryId).toBe(false);
324324
expect(result.errorMessage).toContain("Invalid temporary ID format");
325325
expect(result.errorMessage).toContain("aw_test-id");
326-
expect(result.errorMessage).toContain("3 to 8 alphanumeric characters");
326+
expect(result.errorMessage).toContain("3 to 12 alphanumeric characters");
327327
});
328328

329329
it("should return specific error for malformed temporary ID (too short)", async () => {

actions/setup/js/update_project.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,11 @@ async function updateProject(output, temporaryIdMap = new Map(), githubClient =
703703
// Validate IDs used for draft chaining.
704704
// Draft issue chaining must use strict temporary IDs to match the unified handler manager.
705705
if (temporaryId && !isTemporaryId(temporaryId)) {
706-
throw new Error(`${ERR_VALIDATION}: Invalid temporary_id format: "${temporaryId}". Expected format: aw_ followed by 3 to 8 alphanumeric characters (e.g., "aw_abc", "aw_Test123").`);
706+
throw new Error(`${ERR_VALIDATION}: Invalid temporary_id format: "${temporaryId}". Expected format: aw_ followed by 3 to 12 alphanumeric characters (e.g., "aw_abc", "aw_Test123").`);
707707
}
708708

709709
if (draftIssueId && !isTemporaryId(draftIssueId)) {
710-
throw new Error(`${ERR_VALIDATION}: Invalid draft_issue_id format: "${draftIssueId}". Expected format: aw_ followed by 3 to 8 alphanumeric characters (e.g., "aw_abc", "aw_Test123").`);
710+
throw new Error(`${ERR_VALIDATION}: Invalid draft_issue_id format: "${draftIssueId}". Expected format: aw_ followed by 3 to 12 alphanumeric characters (e.g., "aw_abc", "aw_Test123").`);
711711
}
712712

713713
const draftTitle = typeof output.draft_title === "string" ? output.draft_title.trim() : "";
@@ -939,7 +939,7 @@ async function updateProject(output, temporaryIdMap = new Map(), githubClient =
939939
} else {
940940
// Not a temporary ID - validate as numeric
941941
if (!/^\d+$/.test(sanitizedContentNumber)) {
942-
throw new Error(`${ERR_VALIDATION}: Invalid content number "${rawContentNumber}". Provide a positive integer or a valid temporary ID (format: aw_ followed by 3-8 alphanumeric characters).`);
942+
throw new Error(`${ERR_VALIDATION}: Invalid content number "${rawContentNumber}". Provide a positive integer or a valid temporary ID (format: aw_ followed by 3-12 alphanumeric characters).`);
943943
}
944944
contentNumber = Number.parseInt(sanitizedContentNumber, 10);
945945
}

actions/setup/js/update_project.test.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,12 @@ describe("updateProject", () => {
884884
project: projectUrl,
885885
content_type: "draft_issue",
886886
draft_title: "Test Draft",
887-
temporary_id: "aw_toolong123",
887+
temporary_id: "aw_toolong123456",
888888
};
889889

890890
queueResponses([repoResponse(), viewerResponse(), orgProjectV2Response(projectUrl, 60, "project-draft")]);
891891

892-
await expect(updateProject(output)).rejects.toThrow(/Invalid temporary_id format.*aw_ followed by 3 to 8 alphanumeric characters/);
892+
await expect(updateProject(output)).rejects.toThrow(/Invalid temporary_id format.*aw_ followed by 3 to 12 alphanumeric characters/);
893893
});
894894

895895
it("rejects malformed auto-generated draft_issue_id with aw_ prefix", async () => {
@@ -904,7 +904,7 @@ describe("updateProject", () => {
904904

905905
queueResponses([repoResponse(), viewerResponse(), orgProjectV2Response(projectUrl, 60, "project-draft")]);
906906

907-
await expect(updateProject(output, temporaryIdMap)).rejects.toThrow(/Invalid draft_issue_id format.*aw_ followed by 3 to 8 alphanumeric characters/);
907+
await expect(updateProject(output, temporaryIdMap)).rejects.toThrow(/Invalid draft_issue_id format.*aw_ followed by 3 to 12 alphanumeric characters/);
908908
});
909909

910910
it("rejects draft_issue without title when creating (no draft_issue_id)", async () => {

0 commit comments

Comments
 (0)