[balancewebhooks] Code generation: update services and models#1707
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the BalanceAccountBalanceNotificationRequest and ReleasedBlockedBalanceNotificationRequest models to improve the handling of notification types during deserialization, alongside updating the SDK generation logs. The reviewer identified a potential NullReferenceException risk when assigning the Type property if the source value is null and suggested implementing an explicit null check with an exception. Additionally, a compiler warning was noted regarding a string type mismatch in the FromStringOrDefault method call.
| balanceAccountBalanceNotificationRequest.Data = data.Value!; | ||
| balanceAccountBalanceNotificationRequest.Environment = environment.Value!; | ||
| balanceAccountBalanceNotificationRequest.Type = type.Value!.Value; | ||
| balanceAccountBalanceNotificationRequest.Type = type.Value!; |
There was a problem hiding this comment.
Assigning type.Value! to the non-nullable Type property is risky if the JSON contains an explicit null value for the type field. In such cases, type.Value will be null, and assigning it to a non-nullable property will bypass compiler checks but may cause a NullReferenceException at runtime (e.g., in ToString()). Since this is a required field, it is safer to throw an exception if the value is null. Additionally, note that at line 267, typeRawValue (which is string?) is passed to FromStringOrDefault (which expects string), triggering a compiler warning.
balanceAccountBalanceNotificationRequest.Type = type.Value ?? throw new ArgumentException("Property 'type' cannot be null.", nameof(type));| releasedBlockedBalanceNotificationRequest.Data = data.Value!; | ||
| releasedBlockedBalanceNotificationRequest.Environment = environment.Value!; | ||
| releasedBlockedBalanceNotificationRequest.Type = type.Value!.Value; | ||
| releasedBlockedBalanceNotificationRequest.Type = type.Value!; |
There was a problem hiding this comment.
Assigning type.Value! to the non-nullable Type property is risky if the JSON contains an explicit null value for the type field. In such cases, type.Value will be null, and assigning it to a non-nullable property will bypass compiler checks but may cause a NullReferenceException at runtime. Since this is a required field, it is safer to throw an exception if the value is null. Additionally, note that at line 267, typeRawValue (which is string?) is passed to FromStringOrDefault (which expects string), triggering a compiler warning.
releasedBlockedBalanceNotificationRequest.Type = type.Value ?? throw new ArgumentException("Property 'type' cannot be null.", nameof(type));
This PR contains the automated changes for the
balancewebhooksservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.