Fix duplicate expiration comments on discussions#11690
Merged
Conversation
- Add hasExpirationComment() function to check for existing comments - Skip adding duplicate comments if one already exists - Still close discussions that have comments but remain open - Add comprehensive test coverage for duplicate prevention - Update summary to show skipped discussions count Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix comment addition to closed discussions in agentic maintenance code
Fix duplicate expiration comments on discussions
Jan 24, 2026
pelikhan
reviewed
Jan 24, 2026
| } | ||
|
|
||
| const comments = result.node.comments.nodes || []; | ||
| const expirationCommentPattern = /This discussion was automatically closed because it expired on/; |
- Add <!-- gh-aw-closed --> marker to expiration comments - Check for XML marker instead of text pattern for duplicate detection - Update tests to include XML marker in mock comments Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This was referenced Jan 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Prevent duplicate comments on closed discussions
Problem Analysis
The
close_expired_discussions.cjsscript was adding multiple comments to discussions that should already be closed.Root Cause:
Solution:
hasExpirationComment()function to check for existing comments<!-- gh-aw-closed -->for reliable detectionmake agent-finish)Changes Made
actions/setup/js/close_expired_discussions.cjs:hasExpirationComment()function that queries a discussion's comments to check if an expiration comment already exists<!-- gh-aw-closed -->for reliable duplicate detection (instead of text pattern)actions/setup/js/close_expired_discussions.test.cjs(new file):How It Works
Testing
All new tests pass:
Note: Some pre-existing test failures in
pkg/workfloware unrelated to this change.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.