Skip to content

Add validation error summary with category grouping and severity sorting#4045

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/implement-validation-error-summary
Closed

Add validation error summary with category grouping and severity sorting#4045
Copilot wants to merge 5 commits intomainfrom
copilot/implement-validation-error-summary

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 15, 2025

Implements infrastructure to collect and display multiple validation errors in a structured summary instead of failing on first error. Users get actionable guidance with errors grouped by category and sorted by severity.

Changes

Error Collection Infrastructure (pkg/console/validation_summary.go)

  • ValidationError struct: category, severity, message, file, line, hint
  • FormatValidationSummary(): renders errors grouped by category (Schema, Permissions, Network, Security) and sorted by severity (Critical → High → Medium → Low)
  • Color-coded output with category emojis (❌ 🔒 🌐 🛡️)

Compiler Integration (pkg/workflow/compiler.go)

  • Added validationResults field to accumulate errors
  • Methods: AddValidationError(), AddValidationWarning(), HasValidationErrors()
  • SetCollectErrors(true) enables collection mode

CLI Integration (pkg/cli/compile_command.go)

  • Displays validation summary after compilation when errors exist
  • Respects --verbose flag: summary vs detailed view
  • Works for both single-file and directory compilation

Usage

compiler := workflow.NewCompiler(verbose, engineOverride, version)
compiler.SetCollectErrors(true)

// During validation
compiler.AddValidationError(
    "schema",      // category
    "high",        // severity
    "Invalid field 'enginee', did you mean 'engine'?",
    "workflow.md", // file
    5,            // line
    "Check field spelling",
)

// Display summary
if compiler.HasValidationErrors() {
    results := compiler.GetValidationResults()
    fmt.Fprintln(os.Stderr, console.FormatValidationSummary(results, verbose))
}

Output (non-verbose):

✗ Compilation failed with 6 error(s)

Error Summary:
  Critical: 2 error(s)
  High: 2 error(s)
  Medium: 2 error(s)

By Category:
  🔒 Permissions: 2 error(s)
  ❌ Schema: 2 error(s)
  🌐 Network: 1 error(s)
  🛡️ Security: 1 error(s)

Recommended Fix Order:
  1. Fix schema errors first (typos, invalid fields)
  2. Address permission issues
  3. Configure network access
  4. Review security warnings

ℹ Use --verbose to see detailed error messages

Verbose mode adds detailed errors with file locations, line numbers, and hints for each error sorted by severity.

Testing

  • 6 formatter tests covering grouping, sorting, and display modes
  • 4 error collection tests for compiler integration
  • 2 integration tests with realistic multi-category error scenarios
Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Implement Validation Error Summary Report</issue_title>
<issue_description>## Objective
When compilation fails with multiple validation errors, provide a summary report that groups errors by category, sorts by severity, and suggests a recommended order for fixing them.

Context

Part of Discussion #3956 - Workflow Validation and Error Feedback Quality improvements.

Currently, compilation may fail on the first error. Users need to see all errors at once with intelligent grouping and prioritization to tackle issues efficiently.

Implementation Approach

1. Create Error Collection System

File: pkg/workflow/compiler.go

Add error collection structures:

type ValidationResults struct {
    Errors   []ValidationError
    Warnings []ValidationWarning
}

type ValidationError struct {
    Category string // "schema", "permissions", "network", "security"
    Severity string // "critical", "high", "medium", "low"
    Message  string
    File     string
    Line     int
    Hint     string
}

Update validation flow:

func (c *Compiler) validateWorkflow(frontmatter map[string]any) (*ValidationResults, error) {
    results := &ValidationResults{}
    
    // Collect all errors instead of returning on first error
    if err := c.validateSchema(frontmatter); err != nil {
        results.Errors = append(results.Errors, ValidationError{
            Category: "schema",
            Severity: "high",
            Message:  err.Error(),
        })
    }
    
    if err := c.validatePermissions(frontmatter); err != nil {
        results.Errors = append(results.Errors, ValidationError{
            Category: "permissions",
            Severity: "critical",
            Message:  err.Error(),
        })
    }
    
    // Continue collecting all validation errors
    
    return results, nil
}

2. Create Summary Formatter

File: pkg/console/validation_summary.go

Implement formatting logic:

func FormatValidationSummary(results *ValidationResults) string {
    // Group errors by category
    // Sort by severity (critical → high → medium → low)
    // Format with color coding
    // Add fix order recommendations
    // Include links to error reference
}

Expected output format:

✗ Compilation failed with 5 errors

Error Summary:
  Critical: 1 error
  High: 3 errors
  Medium: 1 error

By Category:
  ❌ Schema Validation: 2 errors
  ⚠️  Permissions: 2 errors
  ⚠️  Network: 1 error

Recommended Fix Order:
  1. Fix schema errors first (typos, invalid fields)
  2. Address permission issues
  3. Configure network access

Use --verbose to see detailed error messages
See (redacted)

3. Update Compiler Output

Files: pkg/cli/compile_command.go

  • Display summary report when multiple errors occur
  • Add --verbose flag to show detailed error messages
  • Ensure backward compatibility with existing error output

Files to Create/Modify

  • Update: pkg/workflow/compiler.go (error collection)
  • Create: pkg/console/validation_summary.go (formatting)
  • Create: pkg/console/validation_summary_test.go (tests)
  • Update: pkg/cli/compile_command.go (display summary)

Acceptance Criteria

  • Collects all validation errors during compilation (don't fail on first error)
  • Groups errors by category: Schema, Permissions, Network, Security, etc.
  • Sorts by severity: Critical → High → Medium → Low
  • Displays summary with error counts per category
  • Shows recommended fix order based on dependencies
  • Links to error reference documentation for each category
  • Includes --verbose flag to show/hide detailed error messages
  • Maintains backward compatibility with existing error output
  • All tests pass (make test-unit)
  • Manual testing confirms improved user experience

Priority

Low - Nice-to-have improvement that enhances multi-error scenarios
Related to #3956

AI generated by Plan Command for discussion #3956</issue_description>

Comments on the Issue (you are @copilot in this section)


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

Copilot AI and others added 4 commits November 15, 2025 13:26
…ementation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…isplay

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add validation error summary report Add validation error summary with category grouping and severity sorting Nov 15, 2025
Copilot AI requested a review from pelikhan November 15, 2025 13:40
@@ -0,0 +1,213 @@
# Validation Error Summary Report - Implementation Summary
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot move to specs root folder

@pelikhan pelikhan closed this Nov 15, 2025
@pelikhan pelikhan deleted the copilot/implement-validation-error-summary branch November 15, 2025 13:54
Copilot AI requested a review from pelikhan November 15, 2025 13:54
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.

[task] Implement Validation Error Summary Report

2 participants