Skip to content

fix: correctly apply version overrides to PAL-based service URLs#489

Open
gourabsingha1 wants to merge 4 commits into
Adyen:mainfrom
gourabsingha1:fix/api-version-override
Open

fix: correctly apply version overrides to PAL-based service URLs#489
gourabsingha1 wants to merge 4 commits into
Adyen:mainfrom
gourabsingha1:fix/api-version-override

Conversation

@gourabsingha1

Copy link
Copy Markdown

Description

This PR resolves issue #474 by fixing a bug in the api_*_version override 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_version used the regex \.com/v\d{1,2} to locate and replace the API version in service base URLs. While this worked for endpoints formatted as https://checkout-test.adyen.com/v71 or https://management-test.adyen.com/v3, it failed for PAL-based endpoints formatted like https://pal-test.adyen.com/pal/servlet/Payment/v68 since they contain /pal/servlet/... between .com and 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

  • Updated _set_url_version in Adyen/client.py to use re.sub(r"/v\d+(\b|$)", f"/{new_version}", endpoint).
  • Added a new unit test test_set_url_version in test/DetermineEndpointTest.py to 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

  • Ran python3 -m unittest test/DetermineEndpointTest.py to verify version overrides and test URL generation.
  • Ran the entire test suite (python3 -m unittest discover -s test -p "*Test.py") and verified all 175 tests pass.

@gourabsingha1 gourabsingha1 requested a review from a team as a code owner June 22, 2026 17:45

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

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.

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.

Comment thread Adyen/client.py Outdated
Comment thread test/DetermineEndpointTest.py Outdated
gourabsingha1 and others added 3 commits June 22, 2026 23:33
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.
@sonarqubecloud

Copy link
Copy Markdown

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