-
Notifications
You must be signed in to change notification settings - Fork 86
Fix pattern addition detection: Change severity from WARN to ERROR for breaking changes #720
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 new error message for pattern additions in English - Add Portuguese (Brazil) translation - Add Russian translation - Update pattern-changed-warn-comment to be more comprehensive
Regenerate localizations.go after adding pattern-added-error-comment
- Add PatternAddedCommentId constant for pattern addition errors - Use PatternAddedCommentId for pattern additions instead of generic PatternChangedCommentId - Keep PatternChangedCommentId for pattern changes (WARN level)
BREAKING CHANGE: Pattern additions are now classified as ERROR level instead of WARN level - RequestParameterPatternAddedId: WARN -> ERR - RequestPropertyPatternAddedId: WARN -> ERR This correctly identifies pattern additions as breaking changes since they restrict previously accepted values.
- Update pattern addition tests to expect ERR level instead of WARN - Update test assertions for new error messages - Verify pattern changes still use WARN level
Pattern additions now have ERR level priority, changing the order of breaking changes in test results. Update expected order in: - TestBreaking_OperationID - TestBreaking_LinkOperationID
|
@reuvenharrison please review this pr |
| config, | ||
| []any{patternDiff.To, paramLocation, paramName}, | ||
| PatternChangedCommentId, | ||
| PatternAddedCommentId, |
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.
nice catch
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #720 +/- ##
=======================================
Coverage 87.58% 87.58%
=======================================
Files 241 241
Lines 13956 13956
=======================================
Hits 12224 12224
Misses 1311 1311
Partials 421 421
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:
|
Problem
Currently, when a pattern validation is added to a previously unrestricted parameter or property, oasdiff incorrectly classifies this as a
WARNlevel change instead of anERRORlevel breaking change.This is problematic because:
Example
Consider this OpenAPI change:
Before (
example_before.yaml):After (
example_after.yaml):This change will break existing clients that were sending non-digit cursor values, but was previously only flagged as a warning.
Solution
This PR implements proper severity classification for pattern-related changes:
Pattern Addition (
pattern added):ERRORlevelPattern Change (
pattern changed):WARNlevel (unchanged)Pattern Generalization (
pattern generalized):INFOlevel (unchanged).*)Pattern Removal (
pattern removed):INFOlevel (unchanged)Changes Made
checker/rules.go:RequestParameterPatternAddedId:WARN→ERRORRequestPropertyPatternAddedId:WARN→ERRORpattern-added-error-commentfor pattern additionspattern-changed-warn-commentto be more comprehensiveVerification
Backward Compatibility
This change only affects the severity classification of pattern additions. The detection logic remains the same, ensuring that: