Warn on malformed #aw_* references in body text#19035
Conversation
Add malformed-ref detection to replaceTemporaryIdReferences() so that body text containing #aw_ prefixed sequences that fail the valid temp ID format (3-8 alphanumeric chars) emit a core.warning() instead of silently passing through as literal text. Fixes #<issue> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
#aw_* references in body text
actions/setup/js/temporary_id.cjs
Outdated
| */ | ||
| function replaceTemporaryIdReferences(text, tempIdMap, currentRepo) { | ||
| // Detect and warn about malformed #aw_ references that won't be resolved | ||
| if (typeof core !== "undefined") { |
actions/setup/js/temporary_id.cjs
Outdated
| function replaceTemporaryIdReferences(text, tempIdMap, currentRepo) { | ||
| // Detect and warn about malformed #aw_ references that won't be resolved | ||
| if (typeof core !== "undefined") { | ||
| const candidatePattern = /#aw_([A-Za-z0-9]+)/gi; |
There was a problem hiding this comment.
@copilot add word boundaries, refactor regex to global variable near other regex so it's centralized
There was a problem hiding this comment.
Done in 8cfae30 — extracted TEMPORARY_ID_CANDIDATE_PATTERN = /#aw_([A-Za-z0-9]+)\b/gi as a module-level constant next to TEMPORARY_ID_PATTERN, with \b word boundary at the end. Also added lastIndex = 0 reset before using the global regex.
…ries - Extract TEMPORARY_ID_CANDIDATE_PATTERN as a module-level constant next to TEMPORARY_ID_PATTERN (with word boundary \b at end) - Remove typeof core guard — core is always defined via shim.cjs - Reset lastIndex before using the global regex in replaceTemporaryIdReferences Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds operator visibility into malformed #aw_* temporary-ID references that appear in body text by emitting warnings during reference replacement.
Changes:
- Introduces
TEMPORARY_ID_CANDIDATE_PATTERNto detect#aw_-prefixed candidate references and warn when they failisTemporaryId(). - Updates
replaceTemporaryIdReferences()to scan body text for malformed temp-ID candidates and callcore.warning(). - Adds unit tests asserting warnings for too-short/too-long
#aw_*references and no warnings for valid references.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actions/setup/js/temporary_id.cjs | Adds candidate detection regex + warning pass before performing normal temp-id replacements; exports new pattern. |
| actions/setup/js/temporary_id.test.cjs | Adds tests validating warning behavior for malformed refs and non-warning for valid refs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * 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; |
There was a problem hiding this comment.
TEMPORARY_ID_CANDIDATE_PATTERN already uses \b and matches any length — no change needed there since the malformed check still delegates to the updated isTemporaryId() (89d3deb).
actions/setup/js/temporary_id.cjs
Outdated
| @@ -29,6 +29,12 @@ const crypto = require("crypto"); | |||
| */ | |||
| const TEMPORARY_ID_PATTERN = /#(aw_[A-Za-z0-9]{3,8})/gi; | |||
There was a problem hiding this comment.
@copilot add word boundary, extend to 12 character long (be lenient with parsing long identifies)
There was a problem hiding this comment.
Done in 89d3deb — TEMPORARY_ID_PATTERN is now /#(aw_[A-Za-z0-9]{3,12})\b/gi with word boundary and extended limit.
…ord boundary
- TEMPORARY_ID_PATTERN: {3,8} → {3,12} and add \b word boundary
- isTemporaryId(): /^aw_[A-Za-z0-9]{3,8}$/ → /^aw_[A-Za-z0-9]{3,12}$/
- Update JSDoc comments to reflect new 3-12 char range
- Tests: 9-char IDs now valid; update "too long" cases to use 13+ chars
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot fix tests |
…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>
Fixed in 53bcf76. The 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
IDs like 'aw_lv1_0000000' contain underscores which are not matched by
TEMPORARY_ID_PATTERN ([A-Za-z0-9]{3,12}), making the test unable to
resolve dependencies. Replace underscore separators with 'n' to produce
valid alphanumeric IDs: 'aw_lv1n0000000' and 'aw_lv2n0n0001'.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in b31a26b. The large-graph test used IDs like |
#aw_refs in body text silently passed through without any warningreplaceTemporaryIdReferences()withcore.warning()TEMPORARY_ID_CANDIDATE_PATTERNas module-level constant next toTEMPORARY_ID_PATTERNwith\bword boundaryif (typeof core !== "undefined")guard —coreis always defined viashim.cjslastIndexbefore using the global regex to avoid state issuesTEMPORARY_ID_CANDIDATE_PATTERNfrom moduleTEMPORARY_ID_PATTERNfrom{3,8}to{3,12}with\bword boundary (lenient parsing)isTemporaryId()from{3,8}to{3,12}to keep validation consistentupdate_project.test.cjs"too long" test case to use 13-char ID (previous 10-char ID now valid)safe_output_topological_sort.test.cjslarge-graph test: replace_-separated IDs (e.g.aw_lv1_0000000) with alphanumeric-only IDs (e.g.aw_lv1n0000000) soTEMPORARY_ID_PATTERNcan match and resolve dependenciesOriginal 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.