Skip to content

fix: lenient temporary ID validation — support underscores, warn instead of fail#24030

Merged
pelikhan merged 3 commits intomainfrom
copilot/be-more-lenient-on-temp-ids
Apr 2, 2026
Merged

fix: lenient temporary ID validation — support underscores, warn instead of fail#24030
pelikhan merged 3 commits intomainfrom
copilot/be-more-lenient-on-temp-ids

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

An invalid temporary_id (e.g. aw_pr_testfix containing an underscore) caused the entire create_pull_request operation to fail. Invalid temp IDs are minor issues and should not abort the workflow.

Changes

  • Underscore support in temp IDs: Updated isTemporaryId regex from [A-Za-z0-9]{3,12} to [A-Za-z0-9_]{3,12}aw_pr_testfix is now a valid ID
  • Warn + auto-generate instead of fail: getOrGenerateTemporaryId and the inline validation in create_pull_request.cjs now emit core.warning() and fall back to an auto-generated ID rather than returning { success: false }
  • Consistent patterns: TEMPORARY_ID_PATTERN and TEMPORARY_ID_CANDIDATE_PATTERN updated to include _
  • Updated error messages: All validation error strings now describe A-Za-z0-9_ as the valid character set with examples like aw_pr_fix
  • update_project.cjs: Error messages updated for consistency (behavior unchanged — draft chaining references still reject truly malformed IDs)
// Before: fails the whole create_pull_request
Error: ✗ Message 2 (create_pull_request) failed: Invalid temporary_id format: 'aw_pr_testfix'. ...

// After: emits a warning, auto-generates a valid ID, and continues
Warning: Invalid temporary_id format: 'aw_pr_testfix'. ... Using auto-generated ID: 'aw_aB3xYz12'

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js D ode-gyp-bin/git git rev-�� --reverse origin/fallback-branch..HEAD node . git odules/npm/node_--count git (http block)
  • invalid.example.invalid
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin https://invalid.example.invalid/nonexistent-repo.git git conf�� user.name Test User ode_modules/.bin/git . git ache/go/1.25.0/x-b git init�� --bare --initial-branch=main 0/x64/bin/git ranch test@test.com ode_modules/.binagent-change.txt git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

- Update isTemporaryId regex to allow underscores (A-Za-z0-9_)
  so IDs like 'aw_pr_testfix' are now valid
- Update TEMPORARY_ID_PATTERN and TEMPORARY_ID_CANDIDATE_PATTERN
  to include underscores for consistent matching
- Change getOrGenerateTemporaryId to warn + auto-generate instead
  of returning an error when format is invalid
- Change create_pull_request.cjs inline validation to warn +
  auto-generate instead of failing the whole PR creation
- Update error messages throughout to mention underscore support
- Update tests to reflect new behavior and new error messages

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8933463a-4aa4-485a-9e85-9ac4a4294ed4

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update PR creation to warn on invalid temporary ID fix: lenient temporary ID validation — support underscores, warn instead of fail Apr 2, 2026
Copilot AI requested a review from pelikhan April 2, 2026 05:51
@github-actions github-actions bot mentioned this pull request Apr 2, 2026
@pelikhan pelikhan marked this pull request as ready for review April 2, 2026 10:03
Copilot AI review requested due to automatic review settings April 2, 2026 10:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes temporary ID handling more permissive and resilient so that malformed temporary_id values no longer abort create_pull_request workflows, while also updating validation messaging and tests to reflect underscore support.

Changes:

  • Expanded temporary ID validation to allow underscores (A-Za-z0-9_) across helper regexes and isTemporaryId.
  • Updated create_pull_request and getOrGenerateTemporaryId to warn and fall back to an auto-generated ID instead of failing on invalid temp IDs.
  • Updated validation/error message text (and corresponding tests) for consistency.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
actions/setup/js/temporary_id.cjs Allows underscores in temp IDs; warns + auto-generates on invalid input; updates validation messages.
actions/setup/js/temporary_id.test.cjs Adds/updates tests for underscore support and the new warn+fallback behavior.
actions/setup/js/create_pull_request.cjs Changes invalid temp ID handling from hard-fail to warning + auto-generated fallback.
actions/setup/js/update_project.cjs Updates validation error messages to reflect underscore support.
actions/setup/js/update_project.test.cjs Updates expectations to match the new validation message wording.
Comments suppressed due to low confidence (2)

actions/setup/js/temporary_id.cjs:142

  • getOrGenerateTemporaryId accepts an entityType parameter (documented as being for error messages) but it’s never used. Either incorporate entityType into the warning / error strings for clearer diagnostics, or remove the parameter to avoid dead API surface.
 * @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") {

actions/setup/js/create_pull_request.cjs:272

  • In the invalid temporary_id path, temporaryId is set to generateTemporaryId() without the .toLowerCase() normalization applied in the valid-id path. For consistency with map lookups (which normalize to lowercase) and to keep returned IDs predictable, consider lowercasing (or using normalizeTemporaryId) on the auto-generated value too.
      if (!isTemporaryId(normalized)) {
        // Warn and auto-generate rather than failing - an invalid temporary_id is a minor issue
        const autoGenerated = generateTemporaryId();
        core.warning(
          `Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric or underscore characters (A-Za-z0-9_). Example: 'aw_abc' or 'aw_pr_fix'. Using auto-generated ID: '${autoGenerated}'`
        );
        temporaryId = autoGenerated;
      } else {
        temporaryId = normalized.toLowerCase();
      }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 33 to 37
* Regex pattern for detecting candidate #aw_ references (any length, word-boundary delimited)
* Used to identify malformed temporary ID references that don't match TEMPORARY_ID_PATTERN
*/
const TEMPORARY_ID_CANDIDATE_PATTERN = /#aw_([A-Za-z0-9]+)\b/gi;
const TEMPORARY_ID_CANDIDATE_PATTERN = /#aw_([A-Za-z0-9_]+)\b/gi;

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEMPORARY_ID_CANDIDATE_PATTERN only matches [A-Za-z0-9_]+ up to a \b, so references that include invalid characters after a valid prefix (e.g. #aw_test-id) will be partially matched as #aw_test and won’t trigger the malformed-reference warning. Consider capturing the full token after #aw_ (up to whitespace/end/punctuation) and then validating the entire candidate so truly malformed IDs get warned about consistently.

Copilot uses AI. Check for mistakes.
Comment on lines 260 to 272
@@ -261,16 +261,15 @@ async function main(config = {}) {
const normalized = rawTemporaryId.startsWith("#") ? rawTemporaryId.substring(1).trim() : rawTemporaryId;

if (!isTemporaryId(normalized)) {
// Warn and auto-generate rather than failing - an invalid temporary_id is a minor issue
const autoGenerated = generateTemporaryId();
core.warning(
`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'`
`Invalid temporary_id format: '${pullRequestItem.temporary_id}'. Temporary IDs must be in format 'aw_' followed by 3 to 12 alphanumeric or underscore characters (A-Za-z0-9_). Example: 'aw_abc' or 'aw_pr_fix'. Using auto-generated ID: '${autoGenerated}'`
);
return {
success: false,
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'`,
};
temporaryId = autoGenerated;
} else {
temporaryId = normalized.toLowerCase();
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file now has a second copy of temporary_id validation + fallback generation logic that overlaps with getOrGenerateTemporaryId in temporary_id.cjs. To avoid future drift (e.g., message wording / normalization differences), consider using the shared helper here and relying on it to warn + generate when invalid.

This issue also appears on line 263 of the same file.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 2, 2026

@copilot review comments

… shared helper in create_pull_request

- TEMPORARY_ID_CANDIDATE_PATTERN now uses [A-Za-z0-9_-]+ (no \b)
  so #aw_test-id captures the full token 'test-id' instead of just
  'test', triggering a warning as expected
- create_pull_request.cjs now uses getOrGenerateTemporaryId() shared
  helper instead of duplicating the validation/fallback logic
- Added test for hyphen-containing malformed temp ID reference

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a6bd2d2f-d14b-45b6-b5aa-61ea6b64360c

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 2, 2026

@copilot review comments

Addressed both review comments in bf2a8a1:

  1. TEMPORARY_ID_CANDIDATE_PATTERN: Changed from [A-Za-z0-9_]+\b to [A-Za-z0-9_-]+ (no word boundary). Now #aw_test-id captures the full token test-id, so aw_test-id correctly fails isTemporaryId and triggers a warning. Added a test to confirm.

  2. Duplicate logic in create_pull_request.cjs: Replaced the inline validation block with a call to the shared getOrGenerateTemporaryId() helper, removing the local copies of isTemporaryId and generateTemporaryId from the import. The behavior is identical — non-string temporary_id still fails, invalid format warns + auto-generates.

@pelikhan pelikhan merged commit eb50750 into main Apr 2, 2026
53 of 56 checks passed
@pelikhan pelikhan deleted the copilot/be-more-lenient-on-temp-ids branch April 2, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalide temporary ID should probably not fail PR creation

3 participants