@@ -66,7 +66,8 @@ class Gitlab:
6666 user_agent: A custom user agent to use for making HTTP requests.
6767 retry_transient_errors: Whether to retry after 500, 502, 503, 504
6868 or 52x responses. Defaults to False.
69- persist_base_url: reconstruct next url if found not same as user provided url
69+ keep_base_url: keep user-provided base URL for pagination if it
70+ differs from response headers
7071 """
7172
7273def __init__ (
@@ -86,7 +87,7 @@ def __init__(
8687order_by :Optional [str ]= None ,
8788user_agent :str = gitlab .const .USER_AGENT ,
8889retry_transient_errors :bool = False ,
89- persist_base_url :bool = False ,
90+ keep_base_url :bool = False ,
9091 )-> None :
9192
9293self ._api_version = str (api_version )
@@ -97,7 +98,7 @@ def __init__(
9798#: Timeout to use for requests to gitlab server
9899self .timeout = timeout
99100self .retry_transient_errors = retry_transient_errors
100- self .persist_base_url = persist_base_url
101+ self .keep_base_url = keep_base_url
101102#: Headers that will be used in request to GitLab
102103self .headers = {"User-Agent" :user_agent }
103104
@@ -1143,19 +1144,20 @@ def _query(
11431144search_api_url = re .search (r"(^.*?/api)" ,next_url )
11441145if search_api_url :
11451146next_api_url = search_api_url .group (1 )
1146- if self ._gl .persist_base_url :
1147+ if self ._gl .keep_base_url :
11471148next_url = next_url .replace (
11481149next_api_url ,f"{ self ._gl ._base_url } /api"
11491150 )
11501151else :
11511152utils .warn (
11521153message = (
1153- f"The base url of the returned next page got "
1154- f"different with the user provided "
1155- f"{ self ._gl .url } /api* ~>{ next_api_url } *, "
1156- f"since this may can lead to unexpected behaviour. "
1157- f"set argument persist_base_url to True for "
1158- f"resonctruct it with the origin one."
1154+ f"The base URL in the server response"
1155+ f"differs from the user-provided base URL "
1156+ f"({ self ._gl .url } /api/ ->{ next_api_url } /). "
1157+ f"This may lead to unexpected behavior and "
1158+ f"broken pagination. Use `keep_base_url=True` "
1159+ f"when initializing the Gitlab instance "
1160+ f"to follow the user-provided base URL."
11591161 ),
11601162category = UserWarning ,
11611163 )