-
Notifications
You must be signed in to change notification settings - Fork 28
Standardize validation error messages with format examples #4017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Created comprehensive error message style guide in .github/instructions/ - Improved error messages in manual_approval.go (2 messages) - Improved error messages in engine_validation.go (4 messages) - Improved error messages in mcp_config_validation.go (8 messages) - Improved error messages in docker_validation.go (1 message) - Updated corresponding tests to match new error message patterns - All tests passing (make test-unit) Error messages now follow the pattern: [what's wrong]. [what's expected]. [example of correct usage] Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…sages - Created comprehensive error message quality tests - Improved runtime_validation.go error messages (1 message) - Improved agent_validation.go error messages (2 messages) - Added test coverage for error message format validation - All tests passing (make test-unit) Total improved: 18 error messages across 6 files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this 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 standardizes validation error messages across the codebase by implementing a consistent three-part format: what's wrong, what's expected, and an example. The changes improve the developer experience by making error messages more actionable and reducing the need to consult documentation when validation fails.
Key Changes
- Created a comprehensive error message style guide in
.github/instructions/error-messages.instructions.md - Improved 18 error messages across 6 validation files with consistent formatting and concrete examples
- Added comprehensive test coverage to validate error message quality
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.github/instructions/error-messages.instructions.md |
New 261-line style guide defining error message template, formatting guidelines, and examples by category |
pkg/workflow/manual_approval.go |
Enhanced 2 error messages with type information and YAML examples |
pkg/workflow/engine_validation.go |
Improved 4 error messages listing valid engines and providing configuration examples |
pkg/workflow/mcp_config_validation.go |
Standardized 8 MCP validation errors with property lists and multi-line YAML examples |
pkg/workflow/docker_validation.go |
Enhanced image not found error with verification guidance and container examples |
pkg/workflow/runtime_validation.go |
Improved secret name validation error with format requirements and example |
pkg/workflow/agent_validation.go |
Enhanced 2 feature support errors with alternative solutions and examples |
pkg/workflow/error_message_quality_test.go |
New 285-line test file with 11 test cases validating error message structure and content |
pkg/workflow/mcp_json_test.go |
Updated 7 test assertions to match new error message format |
pkg/workflow/engine_validation_test.go |
Updated 2 test assertions for standardized engine validation errors |
go.mod, go.sum |
Dependency file updates (no functional changes to dependencies) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| validFields = append(validFields, k) | ||
| } | ||
| sort.Strings(validFields) | ||
| return nil, fmt.Errorf("unknown property '%s' in tool configuration. Valid properties include: %s. Example: tools:\n my-tool:\n command: \"node server.js\"", field, strings.Join(validFields[:10], ", ")) // Show first 10 to keep message reasonable |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential index out of bounds error. The code assumes knownToolFields has at least 10 fields when using validFields[:10], but if the map has fewer than 10 fields, this will panic at runtime.
Since knownToolFields currently has 20+ fields this isn't an immediate issue, but it's fragile if fields are removed in the future. Consider using:
maxFields := 10
if len(validFields) < maxFields {
maxFields = len(validFields)
}
strings.Join(validFields[:maxFields], ", ")| return nil, fmt.Errorf("unknown property '%s' in tool configuration. Valid properties include: %s. Example: tools:\n my-tool:\n command: \"node server.js\"", field, strings.Join(validFields[:10], ", ")) // Show first 10 to keep message reasonable | |
| maxFields := 10 | |
| if len(validFields) < maxFields { | |
| maxFields = len(validFields) | |
| } | |
| return nil, fmt.Errorf("unknown property '%s' in tool configuration. Valid properties include: %s. Example: tools:\n my-tool:\n command: \"node server.js\"", field, strings.Join(validFields[:maxFields], ", ")) // Show up to 10 to keep message reasonable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 8e1004b. Added bounds checking to prevent panic when fewer than 10 fields exist in knownToolFields.
|
@copilot lint |
Add bounds checking before slicing validFields to prevent panic if fewer than 10 fields exist. This addresses the code review comment about potential runtime panic. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Linting completed successfully. All validations passed. |
Error Message Standardization - Complete ✅
Successfully standardized validation error messages across the codebase following the excellent pattern from
time_delta.go.Summary
Created:
Error Message Style Guide (
.github/instructions/error-messages.instructions.md)Error Message Quality Tests (
pkg/workflow/error_message_quality_test.go)Improved 18 Error Messages Across 6 Files:
manual_approval.go- 2 messagesengine_validation.go- 4 messagesmcp_config_validation.go- 8 messagesdocker_validation.go- 1 messageruntime_validation.go- 1 messageagent_validation.go- 2 messagesUpdated Tests:
engine_validation_test.go- Updated error expectationsmcp_json_test.go- Updated error expectationsBug Fixes:
Error Message Pattern
All improved errors follow the template:
Example Improvements
Before:
After:
Before:
After:
Before:
After:
Acceptance Criteria - All Met ✅
.github/instructions/make test-unit)Impact
Error messages are now:
Test Results
Related to #3956
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.