-
Notifications
You must be signed in to change notification settings - Fork 6
HYPERFLEET-452 - feat: implement RFC 9457 Problem Details error model #23
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
HYPERFLEET-452 - feat: implement RFC 9457 Problem Details error model #23
Conversation
WalkthroughThe PR converts the Error model to RFC 9457 Problem Details with HyperFleet extensions: adds a ValidationConstraint enum and ValidationError model; replaces Error fields (id, href, kind) with type, title, status, detail, instance, code, timestamp, trace_id and an errors array of ValidationError; updates ErrorResponse to a single generic ErrorCode and sets Content-Type to application/problem+json. OpenAPI/Swagger manifests and schema files are updated to expose ValidationConstraint and ValidationError and to bump the API version from 1.0.2 to 1.0.3. Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (15)
✏️ Tip: You can disable this entire section by setting Comment |
0222dde to
9185fe9
Compare
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
schemas/core/openapi.yaml (1)
37-42: Add RFC 9457-compliant content type to error responses.Error responses currently generate
application/jsonin the OpenAPI spec, but RFC 9457 (Problem Details for HTTP APIs) specifiesapplication/problem+json. The TypeSpec model defines anErrorResponsewrapper with@header contentType: "application/problem+json", but it's unused—services return the bareErrormodel instead, which lacks the content-type header directive.To fix this, either:
- Add
@header contentType: "application/problem+json";to theErrormodel inmodels/common/model.tsp, or- Refactor service operations to return
ErrorResponse<statusCode>instead of bareErrorOption 1 is simpler and ensures all error responses comply with RFC 9457.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
main.tspmodels/common/model.tspschemas/core/openapi.yamlschemas/gcp/openapi.yamlschemas/gcp/swagger.yaml
🔇 Additional comments (14)
main.tsp (1)
23-23: LGTM! Version bump aligns with breaking change.The version increment to 1.0.3 is appropriate given the breaking change in error response format from custom to RFC 9457 Problem Details.
models/common/model.tsp (4)
46-59: LGTM! ValidationConstraint enum is well-designed.The constraint types cover common validation scenarios. The enum provides meaningful string literals that will serialize consistently in the OpenAPI output.
61-78: LGTM! ValidationError model follows RFC 9457 extension pattern.The model properly extends RFC 9457 with field-level validation details. Using
unknownfor thevaluefield is appropriate to accommodate any data type.
80-122: LGTM! Error model correctly implements RFC 9457 Problem Details.The model properly defines:
- Required fields per RFC 9457:
type,title,status- Optional fields per RFC 9457:
detail,instance- HyperFleet extensions:
code,timestamp,trace_id,errorsFormat decorators (
@format("uri"),@format("date-time")) are correctly applied.
124-128: LGTM! ErrorResponse correctly specifies RFC 9457 content type.The
application/problem+jsoncontent type header is correctly set per RFC 9457 requirements.schemas/core/openapi.yaml (3)
4-4: LGTM! Version aligned across spec files.
917-965: LGTM! Error schema correctly implements RFC 9457.Required fields (
type,title,status) and optional fields are properly defined with appropriate formats and examples.
1292-1325: LGTM! ValidationConstraint and ValidationError schemas are correct.The schemas match the TypeSpec definitions and follow OpenAPI conventions. The
allOfpattern for theconstraintfield properly references the enum while allowing additional metadata.schemas/gcp/openapi.yaml (3)
4-4: LGTM! Version consistent with other spec files.
863-911: LGTM! Error schema consistent with core OpenAPI spec.The RFC 9457 Problem Details implementation mirrors the core spec correctly.
1360-1393: LGTM! Validation schemas consistent with core OpenAPI spec.schemas/gcp/swagger.yaml (3)
19-19: LGTM! Version consistent across all spec files.
985-1033: LGTM! Error definition correctly implements RFC 9457 in Swagger 2.0 format.The required fields (
type,title,status) and property definitions are consistent with the OpenAPI 3.0 specs.
1504-1537: LGTM! Validation definitions correct for Swagger 2.0.The
allOfpattern for theconstraintfield is valid in Swagger 2.0, though some older tools may have limited support. This maintains consistency with the OpenAPI 3.0 specs.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Update Error model to RFC 9457 Problem Details format with HyperFleet extensions: - Add required fields: type, title, status - Add optional fields: detail, instance, code, timestamp, trace_id - Add ValidationError model with field, value, constraint, message - Add ValidationConstraint enum for constraint types - Update ErrorResponse to use application/problem+json content type
9185fe9 to
e813fbf
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rh-amarin The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
aefb9b6
into
openshift-hyperfleet:main
Summary
type,title,statusdetail,instance,code,timestamp,trace_idValidationErrormodel withfield,value,constraint,messageValidationConstraintenum for constraint typesErrorResponseto useapplication/problem+jsoncontent typeTest plan
Related
Breaking Change
This is a breaking change. The error response format changes from custom format to RFC 9457 Problem Details.
Resolves: https://issues.redhat.com/browse/HYPERFLEET-452
Summary by CodeRabbit
New Features
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.