Skip to content

Automated issue triage workflow#5419

Merged
moonbox3 merged 7 commits intomicrosoft:mainfrom
moonbox3:automated-issue-triage
Apr 23, 2026
Merged

Automated issue triage workflow#5419
moonbox3 merged 7 commits intomicrosoft:mainfrom
moonbox3:automated-issue-triage

Conversation

@moonbox3
Copy link
Copy Markdown
Contributor

Motivation and Context

GitHub workflow to automate initial bug reports from issues.

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 self-assigned this Apr 22, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 04:53
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

Adds a new GitHub Actions workflow to automatically triage newly opened issues (and allow manual invocation) by checking reporter team membership and then running DevFlow-based classification/repro steps.

Changes:

  • Introduces .github/workflows/issue-triage.yml to run on issues: opened and workflow_dispatch.
  • Adds a team-membership gate to skip auto-triage for internal reporters.
  • Runs DevFlow scripts to classify spam/relevance and optionally trigger reproduction.

Comment thread .github/workflows/issue-triage.yml Outdated
Comment thread .github/workflows/issue-triage.yml Outdated
Comment thread .github/workflows/issue-triage.yml Outdated
Copy link
Copy Markdown
Contributor Author

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 83%

✓ Correctness

The workflow is structurally sound for normal operation. The three issues from the prior review thread (secret exposure on any opened issue, concurrency group missing workflow_dispatch input, and catch-all error handling in team membership) remain unresolved in the current diff and are the most significant concerns. One new minor finding: the issue-author lookup via the REST API on line 75 does not guard against a null user field (which GitHub returns for deleted accounts), unlike line 68 which uses optional chaining.

✓ Security Reliability

The three main security concerns (unrestricted trigger on issues: opened, concurrency group missing inputs.issue_number, and fail-open on team membership API errors) were already identified in the existing unresolved review thread. Beyond those, the workflow follows good practices: issue number input is regex-validated (line 51), secrets are passed through environment variables rather than expression interpolation (avoiding script injection), and checkouts use persist-credentials: false. No new high-confidence security or reliability issues were found.

✓ Test Coverage

This PR adds a new GitHub Actions workflow for issue triage. From a test coverage perspective, the workflow embeds non-trivial team-membership-check logic as inline JavaScript (lines 67–96) rather than extracting it into a testable script under .github/scripts/, which is the established pattern in this repo (see stale_issue_pr_ping.py with its corresponding test_stale_issue_pr_ping.py). The inline JS includes fallback author resolution, API error handling, and membership state checking — all paths that would benefit from unit tests but currently cannot be tested. The core triage scripts (classify_issue_spam.py, trigger_issue_repro.py) live in an external private repo and are outside the scope of this PR. No blocking test-coverage issues, but the untested inline logic is a notable gap given existing repo conventions.

✓ Design Approach

The workflow is structurally sound: minimal permissions, input validation, credential hygiene (persist-credentials: false), and a two-job gate that skips triage for team members. The three issues raised in the prior review thread (trigger scope allowing any external issue to burn secrets, concurrency group not covering workflow_dispatch inputs, and fail-open error handling in team membership) remain unresolved in this diff and are the most significant design concerns. Beyond those, no new blocking design-approach issues were identified.

Suggestions

  • Line 75: issue.user.login will throw a TypeError for issues opened by deleted GitHub accounts (user is null). Use optional chaining (issue.user?.login) or a null guard, consistent with line 68's context.payload.issue?.user?.login.
  • Extract the inline JavaScript team-membership-check logic (lines 67–96) into a dedicated script under .github/scripts/ (e.g., check_team_membership.js) with unit tests under .github/tests/, following the established stale_issue_pr_ping.py / test_stale_issue_pr_ping.py pattern. This would allow testing the fallback author-resolution, active-membership distinction, and error-handling branches.
  • The 'Stop after spam gate' step (line 155) is a misleading no-op—it logs but doesn't halt execution. The real gating relies on per-step if conditions, so any future step added without its own guard will silently bypass the spam gate. Consider failing the job when spam is detected (labeling is already applied) or restructuring into a separate job so the decision is enforced at the job-dependency level.

Automated review by moonbox3's agents

Comment thread .github/workflows/issue-triage.yml Outdated
Comment thread .github/workflows/issue-triage.yml
Comment thread .github/workflows/issue-triage.yml Outdated
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated Code Review

Reviewers: 4 | Confidence: 87%

✓ Correctness

This workflow closely mirrors the existing devflow-pr-review.yml and follows established repo patterns. The prior review comments (concurrency group missing inputs.issue_number, null-safety on issue.user.login, overly permissive error catch in team check, and the no-op spam gate step) remain the significant correctness concerns. No additional blocking issues were found beyond what has already been flagged.

✓ Security Reliability

The workflow is well-structured and follows existing repository patterns (closely mirrors devflow-pr-review.yml). The most significant security and reliability concerns—fail-open error handling in team membership checks, null-safety on issue.user, concurrency group gaps for workflow_dispatch, and the non-blocking spam gate—have already been identified in the existing review thread. Input validation is solid (regex check on issue_number, all shell variables properly quoted, persist-credentials: false on checkouts). After thorough review, no new high-severity security or reliability issues were found beyond those already flaged.

✓ Test Coverage

This workflow adds non-trivial logic in two untested inline blocks: a bash script that resolves issue metadata with input validation (lines 38–59) and a JavaScript block that resolves the issue author and checks team membership (lines 67–96). The JS block's test gap is already identified in the existing review thread (moonbox3, line 96). However, the bash block's input-validation regex and event-type branching are also testable and currently uncovered. The repo's established convention (.github/scripts/ + .github/tests/, as demonstrated by stale_issue_pr_ping.py) provides a clear pattern for extracting and testing this logic. No new tests are included in this PR.

✓ Design Approach

I did a bounded context pass across the new workflow plus the adjacent automation it builds on (.github/workflows/devflow-pr-review.yml, .github/workflows/label-issues.yml, .github/workflows/stale-issue-pr-ping.yml, and the existing stale-issue script/tests). I did not find any additional design-approach problems beyond the concerns already captured in the unresolved review threads; the remaining issues I considered were either already raised there or would have required guessing about behavior in the private DevFlow scripts.

Suggestions

  • The bash input-validation and event-routing logic in the 'Resolve issue metadata' step (lines 44–57) contains branching and a regex guard that would benefit from test coverage — consider extracting it into a testable script following the .github/scripts/ + .github/tests/ pattern already established by stale_issue_pr_ping.py.

Automated review by moonbox3's agents

Copilot and others added 3 commits April 22, 2026 22:58
Address six review comments on the issue-triage workflow:

1. Change trigger from issues:opened to issues:labeled so the
   secret-backed triage flow is only triggered by a maintainer-
   controlled signal.

2. Include inputs.issue_number in the concurrency group so
   workflow_dispatch runs for the same issue are properly
   de-duplicated.

3. Improve team membership error handling to fail closed: verify
   the team exists before checking membership, and only treat a
   404 as 'not a member' (all other errors fail the job).

4. Use optional chaining (issue.user?.login) for the API-fetched
   issue to handle deleted GitHub accounts without crashing.

5. Extract the inline github-script into a testable module at
   .github/scripts/check_team_membership.js with 10 tests in
   .github/tests/test_check_team_membership.js covering all
   code paths (payload/API author resolution, deleted accounts,
   team lookup failure, 404 vs non-404 membership errors).

6. Make the spam gate actually stop the job by exiting non-zero
   instead of just logging, so future steps cannot accidentally
   run for spam issues.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .github/workflows/issue-triage.yml Outdated
Copilot and others added 2 commits April 23, 2026 09:08
Remove the 'issues' event trigger, keeping only 'workflow_dispatch' so the
workflow can be tested manually before enabling automatic triggers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@moonbox3 moonbox3 merged commit c9e6033 into microsoft:main Apr 23, 2026
17 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.

3 participants