Skip to content

[task] Add examples to compiler.go error messages #4090

Description

@github-actions

Objective

Enhance error messages in pkg/workflow/compiler.go to include actionable examples. The file contains 23 error messages without examples and is critical for user experience as compilation errors are frequently encountered.

Context

Related to #4085 - Repository Quality Improvement Report on Workflow Compilation Error Messages.

The compiler.go file (1617 lines) is the core compilation logic. Currently only 17.28% of errors across the codebase include examples, and compiler errors have significant impact on developer productivity.

Approach

Improve error messages to include actionable examples focusing on:

  1. Schema validation errors - Show valid field names and example configurations
  2. Frontmatter parsing errors - Provide example YAML frontmatter
  3. Import resolution errors - Suggest valid import paths and formats
  4. Workflow structure validation - Include complete workflow examples
  5. Tool configuration errors - Show valid tool setups

Use console formatting functions for consistency:

  • console.FormatError() for structured compiler errors
  • console.FormatErrorWithSuggestions() for errors with actionable hints

Files to Modify

  • Update: pkg/workflow/compiler.go
  • Update: pkg/workflow/compiler_test.go (verify error message quality)

Example Transformations

Schema validation before:

return fmt.Errorf("unknown field: %s", fieldName)

Schema validation after:

return fmt.Errorf("unknown field: %s. Valid fields are: on, permissions, engine, tools, safe-outputs. Example:\n---\non: issues\npermissions:\n  contents: read\n---", fieldName)

Import resolution before:

return fmt.Errorf("failed to resolve import: %s", path)

Import resolution after:

return fmt.Errorf("failed to resolve import: %s. Import paths must start with 'shared/' or '.github/workflows/shared/'. Example: imports:\n  - shared/security-notice.md", path)

Acceptance Criteria

  • All 23+ compilation errors include at least one example of correct usage
  • Schema validation errors show valid field names and types
  • Workflow structure errors include example frontmatter
  • Import resolution errors suggest valid import paths
  • Error messages use console formatting functions where appropriate
  • Tests verify error messages contain "Example:" where applicable

Priority

High - Core compilation errors directly impact all users.
Related to #4085

AI generated by Plan Command for discussion #4085

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions