fix(validate): display all validation errors instead of just the first one - #49
Conversation
- Introduced a new DTD file for opnsense configuration, defining the structure and elements for XML configuration files. - Updated the XSD schema to reflect changes in the configuration structure, including the addition of new elements and attributes. - Removed deprecated elements and adjusted sequences to improve validation accuracy. Tested with `just test` and `just ci-check`, all checks passed successfully.
…elements - Removed multiple deprecated optional elements from the opnsense-config XSD schema to streamline the configuration structure. - Introduced a new `xs:any` element to allow for additional interface names, enhancing flexibility for DHCP configuration. - Updated the schema to reflect standard/reserved interface names while maintaining support for custom naming. Tested with `just test` and `just ci-check`, all checks passed successfully.
…t one - Update AggregatedValidationError.Error() to show all validation errors with numbered list - Modify validate command to properly display all validation issues for each file - Update tests to match new error message format - Fixes issue #32 where only first validation error was shown
|
Caution Review failedThe pull request is closed. Summary by CodeRabbit
WalkthroughThe changes update validation error reporting to display all validation issues in a multi-line format, both in the error aggregation logic and the CLI output. Tests are updated to verify the new error message structure. Additionally, comprehensive OPNsense configuration DTD and expanded XSD schema files are introduced or updated in the test data. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI (validate.go)
participant Parser (errors.go)
participant StdErr
User->>CLI (validate.go): Run validate command
CLI (validate.go)->>Parser (errors.go): Validate file
Parser (errors.go)-->>CLI (validate.go): Return AggregatedValidationError (with all errors)
CLI (validate.go)->>StdErr: Print all validation errors (multi-line)
CLI (validate.go)-->>User: Validation complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #32 by modifying the validation error display to show all validation errors instead of truncating after the first one. The changes ensure network administrators can see all configuration problems at once, improving their ability to prioritize and batch fixes effectively.
- Comprehensive error display in validation output
- Updated error message format to numbered list
- Maintained existing test coverage with updated assertions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/parser/errors.go | Modified AggregatedValidationError.Error() to display all validation errors in numbered format |
| internal/parser/errors_test.go | Updated test assertions to match new comprehensive error message format |
| cmd/validate.go | Enhanced validate command to properly display all validation issues per file |
| testdata/opnsense-config.xsd | Updated XML schema definitions (test data changes) |
| testdata/opnsense-config.dtd | Added comprehensive DTD definitions (test data changes) |
| return fmt.Sprintf("validation failed with %d errors: %s (and %d more)", | ||
| len(r.Errors), r.Errors[0].Message, len(r.Errors)-1) | ||
| // Build a comprehensive error message showing all validation errors | ||
| var sb strings.Builder |
There was a problem hiding this comment.
The strings package should be imported at the top of the file. Add 'strings' to the import statement to ensure the code compiles correctly.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Description
Fixes issue #32 where the validate command only showed the first validation error instead of all validation issues.
Changes Made
Before vs After
Before: Only showed first validation error
After: Shows all validation errors clearly numbered
Testing
Impact
Network administrators can now see all configuration problems at once to prioritize and batch their fixes effectively, significantly improving the user experience when working with configurations that have multiple issues.
Closes #32