Breaking Change in HyperSchema ResponseValidator Status Code Handling
Problem Description
PR #433 introduced a breaking change in the Committee::SchemaValidator::HyperSchema::ResponseValidator that causes validation failures due to overly strict status code matching.
Root Cause
The ResponseValidator now creates validators based on exact status code expectations from link.status_success:
# In ResponseValidator#initialize
@validators[link.status_success] = JsonSchema::Validator.new(target_schema(link))
This creates a rigid mapping:
rel="create" → expects exactly 201
rel="empty" → expects exactly 202
- All others → expect exactly
200
The Issue
When the actual response status code doesn't match the expected link.status_success, validation fails with:
raise InvalidResponse, "Invalid response.#{@link.href} status code #{status} definition does not exist" if @validators[status].nil?
This happens because @validators[status] is nil when the status doesn't match the single expected value.
Impact
This breaks backward compatibility for applications where:
- Create operations return
200 instead of 201
- Async operations return
200 or 204 instead of 202
- Existing working code suddenly fails validation after upgrading
Example Failure Scenario
# Schema defines rel="create" (expects 201)
# But application returns 200 for creates
# Result: ValidationError because @validators[200] is nil
Proposed Solutions
Option 1: Flexible Status Code Ranges
Accept multiple valid status codes per relation type:
def acceptable_statuses(rel)
case rel
when "create" then [200, 201]
when "empty" then [200, 202, 204]
else [200]
end
end
Option 2: Fallback Validation
Try exact status first, then fall back to common success codes:
validator = @validators[status] || @validators[200] || @validators.values.first
Option 3: Configuration Flag
Add strict_status_codes option to allow users to choose validation strictness.
Breaking Change in HyperSchema ResponseValidator Status Code Handling
Problem Description
PR #433 introduced a breaking change in the Committee::SchemaValidator::HyperSchema::ResponseValidator that causes validation failures due to overly strict status code matching.
Root Cause
The ResponseValidator now creates validators based on exact status code expectations from link.status_success:
This creates a rigid mapping:
rel="create"→ expects exactly201rel="empty"→ expects exactly202200The Issue
When the actual response status code doesn't match the expected link.status_success, validation fails with:
This happens because
@validators[status]isnilwhen the status doesn't match the single expected value.Impact
This breaks backward compatibility for applications where:
200instead of201200or204instead of202Example Failure Scenario
Proposed Solutions
Option 1: Flexible Status Code Ranges
Accept multiple valid status codes per relation type:
Option 2: Fallback Validation
Try exact status first, then fall back to common success codes:
Option 3: Configuration Flag
Add
strict_status_codesoption to allow users to choose validation strictness.