fix: correctly apply version overrides to PAL-based service URLs#489
fix: correctly apply version overrides to PAL-based service URLs#489gourabsingha1 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the URL version replacement logic in _set_url_version to use a more generic regular expression and adds corresponding unit tests. The review feedback highlights a potential issue where missing version overrides (valued as None) would incorrectly format the URL with vNone. It is recommended to handle None values by returning the original endpoint unchanged and to add unit tests verifying this behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Resolves reviewer feedback: if a service's version override is not set (None), _set_url_version was incorrectly formatting the URL as '/vNone'. Added a guard that returns the original endpoint unchanged when version is None. Also added test_set_url_version_none_does_not_modify_url to verify this behavior, and wrapped test_set_url_version mutations in a try-finally for state safety.
|



Description
This PR resolves issue #474 by fixing a bug in the
api_*_versionoverride mechanism where version overrides failed to apply to Platform API (PAL) based service URLs (such as Payments, Payouts, Recurring, BinLookup, and StoredValue).Previously,
_set_url_versionused the regex\.com/v\d{1,2}to locate and replace the API version in service base URLs. While this worked for endpoints formatted ashttps://checkout-test.adyen.com/v71orhttps://management-test.adyen.com/v3, it failed for PAL-based endpoints formatted likehttps://pal-test.adyen.com/pal/servlet/Payment/v68since they contain/pal/servlet/...between.comand the version number.This update generalizes the regular expression to identify and replace the version pattern
/v\d+(\b|$)anywhere in the base URL path, ensuring overrides are applied reliably across all service endpoints.Approach
_set_url_versioninAdyen/client.pyto usere.sub(r"/v\d+(\b|$)", f"/{new_version}", endpoint).test_set_url_versionintest/DetermineEndpointTest.pyto verify that overriding version variables (e.g.api_payment_version,api_checkout_version, etc.) correctly modifies the generated URL versions for both checkout and PAL services.Testing
python3 -m unittest test/DetermineEndpointTest.pyto verify version overrides and test URL generation.python3 -m unittest discover -s test -p "*Test.py") and verified all 175 tests pass.