Skip to content

Fix error on unknown recommendation values - #139

Open
francisco-guemes wants to merge 2 commits into
braintree:masterfrom
francisco-guemes:fix-error-on-unknown-recommendation-values
Open

francisco-guemes wants to merge 2 commits into
braintree:masterfrom
francisco-guemes:fix-error-on-unknown-recommendation-values

Conversation

@francisco-guemes

@francisco-guemes francisco-guemes commented Oct 1, 2026 •

Copy link
Copy Markdown

Summary

This pull request improves the robustness of the CustomerRecommendationsPayload class by adding error handling and logging for parsing payment recommendations. The main changes ensure that invalid or missing payment recommendations are gracefully skipped and logged, preventing potential runtime errors.

At the moment if the response from Braintree BE contains values that can not be mapped by the enum RecommendedPaymentOption it throws a ServerException causing to stop the parsing for all payment recommendations.

Error handling and logging improvements

  • Added a Logger to the class and now log warnings when encountering payment recommendations with missing or unknown payment options. [1] [2]
  • Refactored the parsing logic by introducing parsePaymentRecommendation and parsePaymentOption helper methods, which validate input and handle exceptions, returning null for invalid entries.
  • Updated the recommendations extraction to filter out null payment recommendations, ensuring only valid recommendations are processed.

These changes make the code more resilient to malformed data and improve observability for debugging issues related to payment recommendations.

Checklist

  • Added changelog entry
  • Ran unit tests (rake test:unit) --> TZ=UTC mvn test there is test that is sensitive to timezone
  • I alphabetized all attributes, parameters, and methods by name in any class file I changed
  • I have linked the JIRA ticket in the summary section --> NO JIRA ticket associated
  • I have reviewed the JIRA ticket to ensure all AC's are met --> NO JIRA ticket associated
  • I understand that unless this is a Draft PR or has a DO NOT MERGE label, this PR is considered to be in a deploy ready state and can be deployed if merged to main

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.

1 participant