Repository navigation
π§ Patch Release v2.0.3 - Error Handling & Response Validation
π Overview
This patch release improves error handling for malformed JSON responses and corrects the UnregisterResponse class to match real API response structure with proper type conversion.
β¨ Improvements
Enhanced JSON Error Messages
Improved error messages when the API returns invalid JSON responses:
Before:
ApiException: Invalid JSON response from API
After:
ApiException: Invalid JSON response from API: Syntax error. Body: {"api_version":"1.2",...}
Benefits:
- Full response body included in error message (no truncation)
- JSON error details immediately visible
- HTTP status code in error context
- Faster debugging of API issues
Modified: src/Client/ApiClient.php
π Bug Fixes
UnregisterResponse Type Correction
Fixed UnregisterResponse to match actual API response structure:
Before (Incorrect):
public string $modified; // Was expecting string 'Y' or 'N'
public ?string $note; // Using is_string() checkAfter (Correct):
public bool $modified; // Properly converted from 'Y'/'N' to boolean
public ?string $note; // Using TypeConverter::toString()Changes:
modifiedproperty now correctly typed asbool- Uses
TypeConverter::toBool()to convert 'Y'/'N' βtrue/false - Uses
TypeConverter::toString()fornotefield - Added test with real production API response
Modified: src/Response/ApiKey/UnregisterResponse.php
π Migration Guide
For JSON Error Handling
No code changes required. Error messages are now more informative automatically.
For UnregisterResponse Users
If you were checking the modified property:
// Before (string comparison)
if ($response->modified === 'Y') {
// API key was deleted
}
// After (boolean check)
if ($response->modified) {
// API key was deleted
}π§ͺ Quality Assurance
- β 1146/1146 Unit Tests Passing (2296 assertions)
- β PHPStan Level 9: 0 errors (654 files analyzed)
- β PHP CS Fixer: 0 violations
- β New Test: Real production API response validation
π¦ Files Changed
3 files changed: 23 insertions(+), 22 deletions(-)
Modified Files
src/Client/ApiClient.php- Enhanced JSON error messagessrc/Response/ApiKey/UnregisterResponse.php- Correct type conversiontests/Unit/Response/ApiKey/UnregisterResponseTest.php- Boolean assertions
π― Impact
Low Impact
- JSON error improvements: Automatic, no code changes needed
- UnregisterResponse: Only affects users checking
modifiedproperty with string comparison
Recommended Actions
- Update any string comparisons on
modifiedproperty to boolean checks - Benefit from improved error messages automatically
Full Changelog: v2.0.2...v2.0.3