Skip to content

Fix DO_NOT_EDIT detection in PR labeler workflow#3577

Merged
SusanneWindfeldPedersen merged 1 commit into
mainfrom
fix-labeler-regex
May 22, 2026
Merged

Fix DO_NOT_EDIT detection in PR labeler workflow#3577
SusanneWindfeldPedersen merged 1 commit into
mainfrom
fix-labeler-regex

Conversation

@SusanneWindfeldPedersen

Copy link
Copy Markdown
Contributor

Problem

The PR labeler workflow failed to apply the edits-auto-generated label on PRs that modify content inside DO_NOT_EDIT sections (e.g., PR #3576).

Root cause

The regex /(START>DO_NOT_EDIT)([\s\S]*?)(END>DO_NOT_EDIT)/g used a non-greedy match that terminated prematurely at the instructional comment line:

markdown [//]: # (IMPORTANT:Do not edit any of the content between here and the END>DO_NOT_EDIT.)

This line contains END>DO_NOT_EDIT as plain text, so the regex captured only the 2-line header instead of the full protected block.

Fix

  1. Changed regex to require the actual closing marker prefix (IMPORTANT: or <!-- ) before END>DO_NOT_EDIT:
    js /START>DO_NOT_EDIT[\s\S]*?(?:IMPORTANT: END>DO_NOT_EDIT|<!-- END>DO_NOT_EDIT)/g
  2. Now checks both added and removed lines against the block content (previously only checked added lines, missing cases where the original protected text was deleted).
  3. Added early break when detection succeeds to avoid unnecessary iteration.

The non-greedy regex matched prematurely on the instructional comment line containing 'the END>DO_NOT_EDIT' instead of the actual closing marker. Fixed by requiring the closing marker prefix (IMPORTANT: or <!--).

Also checks both added AND removed lines against the block content for more reliable detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 7470fd4:

✅ Validation status: passed

File Status Preview URL Details
.github/workflows/pr-labeler.yml ✅Succeeded

For more details, please refer to the build report.

@SusanneWindfeldPedersen SusanneWindfeldPedersen merged commit 5b6381f into main May 22, 2026
3 checks passed
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.

1 participant