Fix CI pipeline issue in actions workflow#15709
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot keep working |
All TypeScript compilation errors have been fixed! ✅ Changes made (commit e5618d6):
Validation:
All three files now properly handle temporary IDs following the same pattern as |
| core.info(`Using category: ${resolvedCategory.name} (${resolvedCategory.matchType})`); | ||
|
|
||
| // Get or generate the temporary ID for this discussion | ||
| let temporaryId = generateTemporaryId(); |
There was a problem hiding this comment.
@copilot refactor into helper function and reuse
There was a problem hiding this comment.
Refactored into getOrGenerateTemporaryId() helper function in temporary_id.cjs (commit 3e6b5de).
Changes:
- Created reusable helper function that consolidates the temporary ID validation logic
- Updated
create_issue.cjs,create_discussion.cjs, andcreate_project.cjsto use the new helper - Reduced code duplication: 75 lines of duplicated code → 43-line helper function
- All tests passing ✅
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes CI TypeScript @ts-check failures in the safe output JavaScript handlers by centralizing temporary ID handling and correcting an out-of-scope reference in staged preview output.
Changes:
- Added
getOrGenerateTemporaryId()helper to standardize temporary_id generation/validation/normalization. - Updated
create_issue,create_discussion, andcreate_projecthandlers to use the helper (resolving missingtemporaryIdvariable errors). - Removed invalid
titleshorthand property fromcreate_project_status_updatestaged-modepreviewInfo.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/temporary_id.cjs | Adds shared getOrGenerateTemporaryId() helper and exports it. |
| actions/setup/js/create_issue.cjs | Replaces duplicated temporary_id logic with helper usage. |
| actions/setup/js/create_discussion.cjs | Adds temporary_id generation/validation via helper to fix missing variable. |
| actions/setup/js/create_project.cjs | Adds temporary_id generation/validation via helper to fix missing variable. |
| actions/setup/js/create_project_status_update.cjs | Removes invalid title reference from staged preview payload. |
Comments suppressed due to low confidence (1)
actions/setup/js/create_project.cjs:373
- The item_url temporary-id extraction is constrained to
aw_[0-9a-f]{12}and the comment mentionsaw_XXXXXXXXXXXX, but the repository-wide temporary_id format (and isTemporaryId()) isaw_+ 3–8 alphanumeric. As written, valid temporary IDs (e.g. aw_abc123 / aw_Test123 / generated 8-char IDs) will never match and won’t be resolved. Update the regex/comment to align with isTemporaryId()/spec so item_url temporary IDs are actually resolvable.
// Check if item_url contains a temporary ID (either as URL or plain ID)
// Format: https://github.com/owner/repo/issues/#aw_XXXXXXXXXXXX or #aw_XXXXXXXXXXXX
const urlMatch = item_url.match(/issues\/(#?aw_[0-9a-f]{12})\s*$/i);
const plainMatch = item_url.match(/^(#?aw_[0-9a-f]{12})\s*$/i);
if (urlMatch || plainMatch) {
const tempIdStr = (urlMatch && urlMatch[1]) || (plainMatch && plainMatch[1]) || "";
const tempIdWithoutHash = tempIdStr.startsWith("#") ? tempIdStr.substring(1) : tempIdStr;
// Check if it's a valid temporary ID
if (isTemporaryId(tempIdWithoutHash)) {
// Look up in the unified temporaryIdMap
const resolved = temporaryIdMap.get(normalizeTemporaryId(tempIdWithoutHash));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { loadAgentOutput } = require("./load_agent_output.cjs"); | ||
| const { getErrorMessage } = require("./error_helpers.cjs"); | ||
| const { normalizeTemporaryId, isTemporaryId } = require("./temporary_id.cjs"); | ||
| const { normalizeTemporaryId, isTemporaryId, generateTemporaryId, getOrGenerateTemporaryId } = require("./temporary_id.cjs"); |
There was a problem hiding this comment.
generateTemporaryId is imported from temporary_id.cjs but isn’t used in this module anymore (temporary IDs come from getOrGenerateTemporaryId()). Consider removing it from the destructured require to avoid confusion about the source of temporary IDs.
| const { normalizeTemporaryId, isTemporaryId, generateTemporaryId, getOrGenerateTemporaryId } = require("./temporary_id.cjs"); | |
| const { normalizeTemporaryId, isTemporaryId, getOrGenerateTemporaryId } = require("./temporary_id.cjs"); |
| const { getTrackerID } = require("./get_tracker_id.cjs"); | ||
| const { sanitizeTitle, applyTitlePrefix } = require("./sanitize_title.cjs"); | ||
| const { replaceTemporaryIdReferences } = require("./temporary_id.cjs"); | ||
| const { generateTemporaryId, isTemporaryId, normalizeTemporaryId, getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); |
There was a problem hiding this comment.
generateTemporaryId, isTemporaryId, and normalizeTemporaryId are imported here but not referenced anywhere in create_discussion.cjs (only getOrGenerateTemporaryId and replaceTemporaryIdReferences are used). Removing unused imports will make it clearer which temporary-id utilities this handler actually depends on.
| const { generateTemporaryId, isTemporaryId, normalizeTemporaryId, getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); | |
| const { getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); |
| const { generateWorkflowIdMarker } = require("./generate_footer.cjs"); | ||
| const { getTrackerID } = require("./get_tracker_id.cjs"); | ||
| const { generateTemporaryId, isTemporaryId, normalizeTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); | ||
| const { generateTemporaryId, isTemporaryId, normalizeTemporaryId, getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); |
There was a problem hiding this comment.
generateTemporaryId is imported from temporary_id.cjs but is no longer used after switching to getOrGenerateTemporaryId(). Consider removing it from the destructured require to keep the dependency list accurate.
| const { generateTemporaryId, isTemporaryId, normalizeTemporaryId, getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); | |
| const { isTemporaryId, normalizeTemporaryId, getOrGenerateTemporaryId, replaceTemporaryIdReferences } = require("./temporary_id.cjs"); |
| }; | ||
| } | ||
| // At this point, temporaryId is guaranteed to be a string (not null) | ||
| const temporaryId = /** @type {string} */ tempIdResult.temporaryId; |
There was a problem hiding this comment.
create_project now auto-generates a temporaryId via getOrGenerateTemporaryId() when message.temporary_id is missing, but that generated ID isn’t written back onto message.temporary_id and isn’t included in the non-staged return value. As a result, the unified handler manager can’t persist the project mapping (it keys off message.temporary_id) and the caller never receives the auto-generated ID, which contradicts the create_project tool contract (“auto-generated and returned”). Consider setting message.temporary_id to the generated value and/or returning it (e.g. temporaryId) so downstream mapping and follow-up update_project calls work.
| const temporaryId = /** @type {string} */ tempIdResult.temporaryId; | |
| const temporaryId = /** @type {string} */ tempIdResult.temporaryId; | |
| // Persist the generated temporary ID back onto the message so downstream | |
| // handlers that key off message.temporary_id can use it. | |
| message.temporary_id = temporaryId; |
| /** | ||
| * Validate and process a temporary_id from a message | ||
| * Auto-generates a temporary ID if not provided, or validates and normalizes if provided | ||
| * | ||
| * @param {Object} message - The message object that may contain a temporary_id field | ||
| * @param {string} entityType - Type of entity (e.g., "issue", "discussion", "project") for error messages | ||
| * @returns {{temporaryId: string, error: null} | {temporaryId: null, error: string}} Result with temporaryId or error | ||
| */ | ||
| function getOrGenerateTemporaryId(message, entityType = "item") { | ||
| // Auto-generate if not provided |
There was a problem hiding this comment.
In getOrGenerateTemporaryId(), the entityType parameter is documented as being used for error messages but it’s not referenced anywhere in the function. Either remove the parameter from the signature/JSDoc, or incorporate it into the returned error strings so the documentation matches behavior.
| function getOrGenerateTemporaryId(message, entityType = "item") { | ||
| // Auto-generate if not provided | ||
| if (message.temporary_id === undefined || message.temporary_id === null) { | ||
| return { | ||
| temporaryId: generateTemporaryId(), | ||
| error: null, | ||
| }; | ||
| } | ||
|
|
||
| // Validate type | ||
| if (typeof message.temporary_id !== "string") { | ||
| return { | ||
| temporaryId: null, | ||
| error: `temporary_id must be a string (got ${typeof message.temporary_id})`, | ||
| }; | ||
| } | ||
|
|
||
| // Normalize and validate format | ||
| const rawTemporaryId = message.temporary_id.trim(); | ||
| const normalized = rawTemporaryId.startsWith("#") ? rawTemporaryId.substring(1).trim() : rawTemporaryId; | ||
|
|
||
| if (!isTemporaryId(normalized)) { | ||
| return { | ||
| temporaryId: null, | ||
| 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'`, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| temporaryId: normalized.toLowerCase(), | ||
| error: null, | ||
| }; | ||
| } |
There was a problem hiding this comment.
New helper getOrGenerateTemporaryId() is a behavior change (auto-generate, validate, normalize) but there are no unit tests covering its main branches (missing temporary_id, non-string, invalid format, leading #, normalization). Adding targeted tests in temporary_id.test.cjs would help prevent regressions as more handlers adopt this helper.
* Initial plan * Fix TypeScript null check error in create_issue.cjs line 488 Wrap temporaryId with String() before passing to normalizeTemporaryId(). TypeScript's strict null checking was complaining that temporaryId could be null even though we checked for error earlier. The String() wrapper satisfies TypeScript's type system while maintaining the same runtime behavior (normalizeTemporaryId already does String() conversion internally). Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…rt 2 (#15722) * Initial plan * Fix docker_api_proxy_test expectations for LLM gateway support Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fix TypeScript Compilation Errors in Safe Output Handlers
Problem
CI is failing with TypeScript compilation errors in three JavaScript files:
create_discussion.cjs(535,11): Cannot find name 'temporaryId'create_project.cjs(414,13): Cannot find name 'temporaryId'create_project_status_update.cjs(378,13): No value exists in scope for the shorthand property 'title'Solution
Fixed all three TypeScript compilation errors:
create_discussion.cjs: Added missing imports and implemented temporary ID generation logiccreate_project.cjs: Added missing imports and implemented temporary ID validation and generation logiccreate_project_status_update.cjs: Removed incorrecttitlereference frompreviewInfoobject in staged modeRefactoring
Created reusable helper function
getOrGenerateTemporaryId()intemporary_id.cjsto eliminate code duplication:create_issue.cjs,create_discussion.cjs, andcreate_project.cjsto use the new helperChanges Made
create_discussion.cjs: Added missingtemporaryIdvariable generationcreate_project.cjs: Added missingtemporaryIdvariable generationcreate_project_status_update.cjs: Removed incorrecttitlereference inpreviewInfogetOrGenerateTemporaryId()helper functionAll three files now use the centralized helper function for temporary ID handling, reducing duplication and improving maintainability.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.