-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Labels
Description
Objective
Enhance schema validation error messages to provide inline examples rather than just referencing the schema. When validation fails, show the user exactly what correct YAML should look like.
Context
Part of discussion #4071 - Repository Quality Improvement. Schema validation errors currently return generic messages that reference the schema but don't provide actionable examples. This forces users to search documentation.
Approach
- Enhance
pkg/workflow/schema_validation.goto parse schema validation errors and identify which field failed - Create a helper function
extractFieldFromSchemaError()to parse JSON schema validation errors - Build a map of common field examples for quick lookup
- Provide field-specific examples based on the failed field
Files to Modify
- Update:
pkg/workflow/schema_validation.go - Update:
pkg/workflow/schema_validation_test.go - Create: Helper function for field extraction and example mapping
Example Improvements
Current behavior:
return fmt.Errorf("GitHub Actions schema validation failed: %w", err)Improved behavior for timeout-minutes:
GitHub Actions schema validation failed for 'timeout-minutes': must be an integer. Example: timeout-minutes: 10
Improved behavior for engine:
GitHub Actions schema validation failed for 'engine': invalid value. Valid engines are: copilot, claude, codex, custom. Example: engine: copilot
Improved behavior for permissions:
GitHub Actions schema validation failed for 'permissions': must be an object with permission levels. Example: permissions:\\n contents: read\\n issues: write
Implementation Steps
- Add helper function to extract field name from schema validation error message
- Create map of field-specific examples for common fields:
- timeout-minutes, engine, permissions, on, tools, etc.
- Enhance
validateGitHubActionsSchema()to parse the error and provide targeted examples - Add comprehensive tests for different schema validation failure scenarios
Acceptance Criteria
- Schema validation errors extract field name from validation error
- Field-specific examples are provided based on the failed field
- Common schema violations (type mismatches, missing fields) have tailored examples
- Error messages reference both the schema issue and provide inline examples
- Tests verify example inclusion in schema validation errors
- Handle cases where field name cannot be extracted (fallback to generic message)
- Run
make test-unitto verify all tests pass
AI generated by Plan Command for discussion #4071
Copilot