@@ -66,7 +66,8 @@ class Gitlab:
66
66
user_agent: A custom user agent to use for making HTTP requests.
67
67
retry_transient_errors: Whether to retry after 500, 502, 503, 504
68
68
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
70
71
"""
71
72
72
73
def __init__ (
@@ -86,7 +87,7 @@ def __init__(
86
87
order_by : Optional [str ] = None ,
87
88
user_agent : str = gitlab .const .USER_AGENT ,
88
89
retry_transient_errors : bool = False ,
89
- persist_base_url : bool = False ,
90
+ keep_base_url : bool = False ,
90
91
) -> None :
91
92
92
93
self ._api_version = str (api_version )
@@ -97,7 +98,7 @@ def __init__(
97
98
#: Timeout to use for requests to gitlab server
98
99
self .timeout = timeout
99
100
self .retry_transient_errors = retry_transient_errors
100
- self .persist_base_url = persist_base_url
101
+ self .keep_base_url = keep_base_url
101
102
#: Headers that will be used in request to GitLab
102
103
self .headers = {"User-Agent" : user_agent }
103
104
@@ -1143,19 +1144,20 @@ def _query(
1143
1144
search_api_url = re .search (r"(^.*?/api)" , next_url )
1144
1145
if search_api_url :
1145
1146
next_api_url = search_api_url .group (1 )
1146
- if self ._gl .persist_base_url :
1147
+ if self ._gl .keep_base_url :
1147
1148
next_url = next_url .replace (
1148
1149
next_api_url , f"{ self ._gl ._base_url } /api"
1149
1150
)
1150
1151
else :
1151
1152
utils .warn (
1152
1153
message = (
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."
1159
1161
),
1160
1162
category = UserWarning ,
1161
1163
)
0 commit comments