Skip to content

[legalentitymanagement] Code generation: update services and models#1715

Merged
gcatanese merged 1 commit into
mainfrom
sdk-automation/legalentitymanagement
May 21, 2026
Merged

[legalentitymanagement] Code generation: update services and models#1715
gcatanese merged 1 commit into
mainfrom
sdk-automation/legalentitymanagement

Conversation

@AdyenAutomationBot
Copy link
Copy Markdown
Collaborator

This PR contains the automated changes for the legalentitymanagement service.

The commit history of this PR reflects the adyen-openapi commits that have been applied.

@AdyenAutomationBot AdyenAutomationBot requested a review from a team as a code owner May 21, 2026 12:55
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates numerous model files in the Legal Entity Management module to improve enum handling during serialization and deserialization, specifically adding fallback logic for unknown values. Review feedback identifies a critical risk of NullReferenceException in the enum conversion operators across several files. Additionally, the updated logic in BankAccountInfoAccountIdentification was flagged for potentially breaking forward compatibility with the API and introducing unnecessary performance overhead due to redundant string conversions and lookups.

Comment on lines 131 to +134
if (value == TypeEnum.AuLocal)
return "auLocal";

return null;
return value.Value;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The conversion operator is missing a null check for the value parameter. If value is null, the equality check value == TypeEnum.AuLocal will be false, and the subsequent access to value.Value will throw a NullReferenceException. This will cause crashes during serialization of any object where this enum property is null. This pattern appears to be repeated across all model files in this pull request.

                if (value == TypeEnum.AuLocal)
                    return "auLocal";
                
                return value?.Value;

Comment on lines +424 to 467
if (aULocalAccountIdentification?.Type != null && AULocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)aULocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(aULocalAccountIdentification);

if (cALocalAccountIdentification?.Type != null)
if (cALocalAccountIdentification?.Type != null && CALocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)cALocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(cALocalAccountIdentification);

if (cZLocalAccountIdentification?.Type != null)
if (cZLocalAccountIdentification?.Type != null && CZLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)cZLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(cZLocalAccountIdentification);

if (dKLocalAccountIdentification?.Type != null)
if (dKLocalAccountIdentification?.Type != null && DKLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)dKLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(dKLocalAccountIdentification);

if (hKLocalAccountIdentification?.Type != null)
if (hKLocalAccountIdentification?.Type != null && HKLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)hKLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(hKLocalAccountIdentification);

if (hULocalAccountIdentification?.Type != null)
if (hULocalAccountIdentification?.Type != null && HULocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)hULocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(hULocalAccountIdentification);

if (ibanAccountIdentification?.Type != null)
if (ibanAccountIdentification?.Type != null && IbanAccountIdentification.TypeEnum.FromStringOrDefault((string?)ibanAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(ibanAccountIdentification);

if (nOLocalAccountIdentification?.Type != null)
if (nOLocalAccountIdentification?.Type != null && NOLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)nOLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(nOLocalAccountIdentification);

if (nZLocalAccountIdentification?.Type != null)
if (nZLocalAccountIdentification?.Type != null && NZLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)nZLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(nZLocalAccountIdentification);

if (numberAndBicAccountIdentification?.Type != null)
if (numberAndBicAccountIdentification?.Type != null && NumberAndBicAccountIdentification.TypeEnum.FromStringOrDefault((string?)numberAndBicAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(numberAndBicAccountIdentification);

if (pLLocalAccountIdentification?.Type != null)
if (pLLocalAccountIdentification?.Type != null && PLLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)pLLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(pLLocalAccountIdentification);

if (sELocalAccountIdentification?.Type != null)
if (sELocalAccountIdentification?.Type != null && SELocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)sELocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(sELocalAccountIdentification);

if (sGLocalAccountIdentification?.Type != null)
if (sGLocalAccountIdentification?.Type != null && SGLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)sGLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(sGLocalAccountIdentification);

if (uKLocalAccountIdentification?.Type != null)
if (uKLocalAccountIdentification?.Type != null && UKLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)uKLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(uKLocalAccountIdentification);

if (uSLocalAccountIdentification?.Type != null)
if (uSLocalAccountIdentification?.Type != null && USLocalAccountIdentification.TypeEnum.FromStringOrDefault((string?)uSLocalAccountIdentification.Type) != null)
return new BankAccountInfoAccountIdentification(uSLocalAccountIdentification);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for identifying the correct account identification type has become significantly more restrictive and computationally expensive. By checking FromStringOrDefault(...) != null, the code now explicitly rejects any 'unknown' enum values that might be sent by the API for forward compatibility. If the API introduces a new type that should map to one of these classes but isn't yet in the SDK's hardcoded list, deserialization will now fail with a JsonException instead of potentially succeeding with an 'unknown' enum value. Additionally, performing a string conversion and a dictionary lookup for every single type check in a long if-else chain is inefficient.

@gcatanese gcatanese added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 913c4fe May 21, 2026
2 checks passed
@gcatanese gcatanese deleted the sdk-automation/legalentitymanagement branch May 21, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants