Skip to content

Add workflow to detect new NETSDK diagnostics in PRs#52854

Open
Copilot wants to merge 6 commits intomainfrom
copilot/add-github-actions-workflow-again
Open

Add workflow to detect new NETSDK diagnostics in PRs#52854
Copilot wants to merge 6 commits intomainfrom
copilot/add-github-actions-workflow-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Implementation Plan: NETSDK Diagnostic Detection Workflow

✅ All requirements implemented and security feedback addressed

Key Changes (Latest)

  • Separated into 3 jobs for minimal permissions:
    • read-diff: Checkout and read git diff (read-only permissions)
    • detect-diagnostics: Parse and detect NETSDK codes (no permissions)
    • apply-label-and-comment: Apply label and post comment (write permissions only)
  • Removed temp file usage: Now uses job outputs for passing data between jobs
  • Added security measures:
    • Cleared GITHUB_TOKEN and GH_TOKEN in git operations
    • Added 1MB size limit on diff to prevent resource exhaustion
    • Limited permissions per job to minimum required
  • Global permissions: Set to read-all with per-job overrides

Summary

✅ Uses git diff -- '*.xlf' for precise file filtering
✅ Safe for fork PRs (pull_request_target + minimal permissions)
✅ Job outputs instead of temp files
✅ Size validation (1MB limit)
✅ Token clearing for security
✅ Separated concerns with appropriate permissions per job

Original prompt

Add a GitHub Actions workflow to dotnet/sdk that detects when a pull request introduces new .NET SDK diagnostic codes (messages prefixed with NETSDK####:) and automatically flags the PR so documentation in dotnet/docs can be updated.

Requirements:

  • Repo: dotnet/sdk
  • Base branch: main
  • Create/apply a new label named sdk-diagnostic-docs-needed when a PR introduces new NETSDK diagnostics.
  • Add a PR comment reminding contributors to update the SDK diagnostic docs in dotnet/docs at docs/core/tools/sdk-errors.
  • Detection should be safe for PRs from forks; prefer using pull_request_target with minimal permissions and avoid executing untrusted code.
  • Detection logic should look at the diff between base and PR head and identify newly-added lines containing NETSDK diagnostic code prefixes (regex like NETSDK[0-9]{4}:).
  • If no new diagnostics are found, do nothing.
  • Ensure the workflow has necessary permissions to add labels and comment on PRs.

Acceptance criteria:

  • Opening a PR that adds a new message containing NETSDK1234: causes the workflow to apply the label sdk-diagnostic-docs-needed and posts (or updates) a reminder comment.
  • The workflow does not run arbitrary code from the PR (no dotnet build etc.); it only uses git diff / grep style checks.

Implementation notes:

  • If the label does not exist yet, the workflow should create it (using GitHub API) or otherwise fail gracefully with an actionable message. Prefer creating it automatically.
  • Use a sticky comment approach (update an existing comment from github-actions bot if already present) to avoid comment spam.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add GitHub Actions workflow for .NET SDK diagnostics Add workflow to detect new NETSDK diagnostics in PRs Feb 5, 2026
Copilot AI requested a review from baronfel February 5, 2026 17:45
Copilot AI and others added 5 commits February 5, 2026 11:45
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
@baronfel baronfel force-pushed the copilot/add-github-actions-workflow-again branch from 2d4d686 to 239ea9b Compare February 5, 2026 17:45
@baronfel baronfel marked this pull request as ready for review February 5, 2026 17:45
Copilot AI review requested due to automatic review settings February 5, 2026 17:45
Copy link
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 adds a GitHub Actions workflow to automatically detect new .NET SDK diagnostic codes (NETSDK####) in pull requests and flag them for documentation updates in the dotnet/docs repository.

Changes:

  • Introduces automated detection of new NETSDK diagnostic codes in .xlf translation files
  • Applies sdk-diagnostic-docs-needed label when new diagnostics are found
  • Posts/updates sticky PR comment reminding contributors to update SDK diagnostic documentation

@baronfel
Copy link
Member

baronfel commented Feb 5, 2026

@copilot respond to Noah's feedback.

…tokens, add size check

Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot respond to Noah's feedback.

All feedback addressed in commit 0ef8c3e:

  • ✅ Switched from temp file to job outputs using multiline string format
  • ✅ Split into 3 jobs with minimal permissions per job:
    • Reading step: read-only
    • Computation step: no permissions
    • Writing step: write-only
  • ✅ Added size check (1MB limit) and token clearing for security

@baronfel
Copy link
Member

baronfel commented Feb 6, 2026

@nagilson if you want to take another look, I think most of your feedback has been addressed!

@baronfel baronfel enabled auto-merge (squash) February 6, 2026 19:00
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