-
Notifications
You must be signed in to change notification settings - Fork 6
feat: implement structured validation error responses #38
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
- Add ValidationError and FieldViolation messages - Support field-level validation error details - Enable JSON/protobuf serialization for error responses 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add writeValidationErrorResponse() for content-type aware error serialization - Add writeValidationError() to convert protovalidate errors to ValidationError - Update validateHeaders() to return ValidationError directly - Replace plain text http.Error() calls with structured error responses - Support both JSON and protobuf error response formats based on content-type - Extract field paths from protovalidate violations for detailed error reporting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Include errors.proto in protoc compilation - Add proper go_opt mapping for errors.proto 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove admin.proto and admin_service.proto - Focus example on core user service functionality - Reduce complexity for testing and demonstration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add replace directive to use local sebuf for testing - Ensure examples use latest local changes during development 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update annotations.pb.go and headers.pb.go - Regenerated with protoc v6.32.0 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Document ValidationError message structure with field violations - Update error examples to show JSON response format - Add examples of multiple validation failures - Update features list to include structured errors and content-type awareness - Show both header and body validation error responses 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update generated validation code examples to show ValidationError returns - Modify header validation examples to show JSON error responses - Add structured errors to features list - Update curl examples with proper JSON error format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update validation error examples to show JSON response format - Add examples of multiple validation failures - Remove references to deleted AdminService - Simplify OpenAPI documentation references - Add structured error responses to features list 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add ValidationError and FieldViolation schemas to OpenAPI components - Include 400 validation error responses in all method specifications - Provide comprehensive error documentation for API consumers - Support both request body and header validation error reporting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Format long function signature lines for better readability - Maintain consistent code style across generator functions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Split generateErrorResponseFunctions into smaller helper functions - Split generateValidateHeadersFunction into smaller helper functions - Fix funlen linting violations (functions > 50 statements) - Maintain same generated code behavior with improved readability 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add FieldViolation and ValidationError schemas to all golden files - Include 400 validation error responses in method specifications - Update both YAML and JSON golden file formats - Reflect new OpenAPI generator behavior for validation errors 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove .generated files created during golden file testing - Clean up test artifacts that shouldn't be committed - These files are created during UPDATE_GOLDEN test runs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit d6db39d.
- Remove temporary .generated files created during golden file testing - These files are test artifacts and shouldn't be committed - They are created during UPDATE_GOLDEN test runs for comparison 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Prevent temporary .generated test files from being committed - These files are created during golden file testing for comparison - Should be automatically cleaned up after test runs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🔍 CI Pipeline Status✅ Lint: success 📊 Coverage Report: Available in checks above |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
+ Coverage 10.61% 13.77% +3.16%
==========================================
Files 5 5
Lines 1046 1096 +50
==========================================
+ Hits 111 151 +40
- Misses 930 940 +10
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
This PR implements comprehensive structured validation error responses across the sebuf toolkit, providing consistent error handling for both request body and header validation.
Key Changes
Add ValidationError proto definitions (
proto/sebuf/http/errors.proto
)ValidationError
message with list of field violationsFieldViolation
message with field path and descriptionUpdate HTTP generator (
internal/httpgen/generator.go
)Update OpenAPI v3 generator (
internal/openapiv3/generator.go
)Refactor for code quality
Update documentation and examples
Error Response Format
Benefits
Test Plan
🤖 Generated with Claude Code