-
Notifications
You must be signed in to change notification settings - Fork 145
[relayedauthorizationwebhooks] Code generation: update services and models #1669
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
base: main
Are you sure you want to change the base?
[relayedauthorizationwebhooks] Code generation: update services and models #1669
Conversation
Summary of ChangesHello @AdyenAutomationBot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces new models and a webhook handler for relayed authorization webhooks. The changes appear to be automatically generated, likely from an OpenAPI specification. The overall structure and implementation follow standard patterns for data models and webhook processing. However, there are a few areas that could be improved for robustness and clarity, particularly concerning enum handling and exception management.
| LOG.warning( | ||
| "AmountAdjustmentTypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(AmountAdjustmentTypeEnum.values())); | ||
| return null; |
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.
The fromValue method for AmountAdjustmentTypeEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| // handling unexpected value | ||
| LOG.warning( | ||
| "StatusEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(StatusEnum.values())); |
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.
The fromValue method for StatusEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| LOG.warning( | ||
| "FormFactorEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(FormFactorEnum.values())); | ||
| return null; |
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.
The fromValue method for FormFactorEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| LOG.warning( | ||
| "TypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(TypeEnum.values())); | ||
| return null; |
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.
The fromValue method for TypeEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| // handling unexpected value | ||
| LOG.warning( | ||
| "StatusEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(StatusEnum.values())); |
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.
The fromValue method for StatusEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| // handling unexpected value | ||
| LOG.warning( | ||
| "StatusReasonEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(StatusReasonEnum.values())); |
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.
The fromValue method for StatusReasonEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| LOG.warning( | ||
| "TypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(TypeEnum.values())); | ||
| return null; |
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.
The fromValue method for TypeEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| LOG.warning( | ||
| "TypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(TypeEnum.values())); | ||
| return null; |
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.
The fromValue method for TypeEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| // handling unexpected value | ||
| LOG.warning( | ||
| "TypeEnum: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(TypeEnum.values())); |
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.
The fromValue method for TypeEnum returns null when an unexpected value is encountered. This can lead to NullPointerExceptions if the calling code does not explicitly check for null. It's generally safer to throw an IllegalArgumentException for invalid input or define an UNKNOWN enum value to handle such cases gracefully.
// handling unexpected value
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}| T val = JSON.getMapper().readValue(payload, clazz); | ||
| return Optional.ofNullable(val); | ||
| } catch (Exception e) { | ||
| // an error has occurred during deserialization (object not found, deserialization error) | ||
| LOG.warning("Object not found or unexpected error trying to access: " + clazz.getName()); | ||
| LOG.warning("Deserialization error: " + e.getMessage()); | ||
| return Optional.empty(); |
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.
Catching a general Exception is too broad and can mask other issues. It's better to catch specific exceptions like JsonProcessingException for deserialization errors. This improves error handling clarity and prevents unintended suppression of other runtime exceptions.
try {
T val = JSON.getMapper().readValue(payload, clazz);
return Optional.ofNullable(val);
} catch (JsonProcessingException e) {
LOG.warning("Deserialization error for " + clazz.getName() + ": " + e.getMessage());
return Optional.empty();
} catch (Exception e) {
// Handle other unexpected exceptions
LOG.warning("Unexpected error trying to access: " + clazz.getName() + ": " + e.getMessage());
return Optional.empty();
}9e844c4 to
05d726c
Compare
This PR contains the automated changes for the
relayedauthorizationwebhooksservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.