Skip to content

Prettify permissions validation error messages#2798

Merged
pelikhan merged 6 commits into
mainfrom
copilot/pretify-permissions-error-message
Oct 30, 2025
Merged

Prettify permissions validation error messages#2798
pelikhan merged 6 commits into
mainfrom
copilot/pretify-permissions-error-message

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 30, 2025

Permissions validation error messages contained redundant prefixes and verbose formatting that made them harder to scan. The compiler already adds "error:" and "warning:" labels, making the "ERROR:" and "WARNING:" prefixes in the message text redundant.

Changes

  • Remove redundant prefixes: Drop "ERROR:" and "WARNING:" from message text (compiler adds these)
  • Inline toolset context: Show (required by <toolset>) next to each permission instead of separate "Required by toolsets:" section
  • Simplify branding: Change "GitHub MCP toolsets" → "github toolsets"
  • Reduce verbosity: Remove unnecessary phrases like "Suggested fix:" and "Principle of least privilege:"

Before/After

Missing permissions:

- ERROR: Missing required permissions for GitHub MCP toolsets:
+ Missing required permissions for github toolsets:
    - issues: read
-   - pull-requests: read
- 
- Required by toolsets:
-   - issues: needs issues
-   - pull_requests: needs pull-requests
- 
- Suggested fix: Add the following to your workflow frontmatter:
+   - pull-requests: read (required by pull_requests)
+ 
+ Add to your workflow frontmatter:
  permissions:
    issues: read
    pull-requests: read

Excess permissions:

- WARNING: Over-provisioned permissions detected for GitHub MCP toolsets:
-   - issues: write (not required by configured toolsets)
+ Over-provisioned permissions detected for github toolsets:
+   - issues: write (not required)
  
- Principle of least privilege: Only grant permissions that are needed.
- Consider removing these permissions or adjusting your toolsets configuration.
+ Only grant permissions that are needed.

Result: 45% fewer lines for missing permissions, 50% fewer for excess permissions.

Original prompt

Pretify the permissions error message.

  • avoid ERROR/WARNING as they are already rendered
  • make it more compact
  • GitHub MCP -> "github"
  • merge Required by toolsets:... into error description.
pkg/cli/workflows/test-template-github-actions-syntax.md:1:1: error: ERROR: Missing required permissions for GitHub MCP toolsets:
  - issues: read
  - pull-requests: read

Required by toolsets:
  - issues: needs issues
  - pull_requests: needs pull-requests

Suggested fix: Add the following to your workflow frontmatter:
permissions:
  issues: read
  pull-requests: read

pkg/cli/workflows/test-template-issue-context.md:1:1: error: ERROR: Missing required permissions for GitHub MCP toolsets:
  - pull-requests: read

Required by toolsets:
  - pull_requests: needs pull-requests

Suggested fix: Add the following to your workflow frontmatter:
permissions:
  pull-requests: read

WARNING: Over-provisioned permissions detected for GitHub MCP toolsets:
  - issues: write (not required by configured toolsets)

Principle of least privilege: Only grant permissions that are needed.
Consider removing these permissions or adjusting your toolsets configuration.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits October 30, 2025 14:49
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Remove ERROR/WARNING prefixes (already rendered by compiler)
- Change "GitHub MCP" to "github"
- Make messages more compact by merging toolset details inline
- Update "Required by toolsets:" to show inline as "(required by X)"
- Simplify excess permissions message
- Update test expectations to match new format
- Fix test using allowed: instead of toolsets:

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Pretify permissions error message for GitHub MCP Prettify permissions validation error messages Oct 30, 2025
Copilot AI requested a review from pelikhan October 30, 2025 15:29
@pelikhan pelikhan marked this pull request as ready for review October 30, 2025 15:30
Copilot AI review requested due to automatic review settings October 30, 2025 15:30
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request.

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

This PR modernizes and simplifies permissions validation error messages by removing redundant prefixes, reducing verbosity, and inlining contextual information. The changes make error messages more scannable while maintaining all essential information.

Key changes:

  • Remove redundant "ERROR:" and "WARNING:" prefixes since the compiler already adds these labels
  • Inline toolset context directly with each permission instead of using a separate "Required by toolsets:" section
  • Simplify branding from "GitHub MCP toolsets" to "github toolsets"

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/workflow/permissions_validator.go Main implementation of improved error message formatting with inline toolset context
pkg/workflow/permissions_validator_test.go Updated test expectations to match new message format
pkg/workflow/permissions_excess_compilation_test.go Updated warning detection logic and expected messages
pkg/workflow/compiler_test.go Minor test configuration update
pkg/workflow/schemas/github-workflow.json Schema formatting improvements (unrelated to main PR purpose)
.github/workflows/*.lock.yml GitHub Actions version updates (unrelated to main PR purpose)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +305 to +312
for toolset, toolsetScopes := range result.MissingToolsetDetails {
for _, ts := range toolsetScopes {
if ts == scope {
requiredBy = append(requiredBy, toolset)
break
}
}
}
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

The nested loop creates O(n*m) complexity for finding which toolsets require each permission. Consider pre-computing a reverse map from scope to toolsets to improve performance when there are many toolsets and permissions.

See below for a potential fix:


	// Precompute reverse map: scope -> toolsets
	scopeToToolsets := make(map[PermissionScope][]string)
	if len(result.MissingToolsetDetails) > 0 {
		for toolset, toolsetScopes := range result.MissingToolsetDetails {
			for _, ts := range toolsetScopes {
				scopeToToolsets[ts] = append(scopeToToolsets[ts], toolset)
			}
		}
	}

	for _, scopeStr := range scopes {
		scope := PermissionScope(scopeStr)
		level := result.MissingPermissions[scope]

		// Lookup which toolsets need this permission
		requiredBy := scopeToToolsets[scope]

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit d4f836a into main Oct 30, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/pretify-permissions-error-message branch October 30, 2025 15:40
@lpcox lpcox mentioned this pull request May 10, 2026
6 tasks
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