From 501291d7322207920f3bfb27c03386e889caa14b Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Wed, 6 Aug 2025 13:16:03 +0200 Subject: [PATCH 1/6] add query params that are added to the url but not quoted --- mergin/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mergin/client.py b/mergin/client.py index 4f91fb95..46049311 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -273,8 +273,10 @@ def get(self, path, data=None, headers={}, validate_auth=True): request = urllib.request.Request(url, headers=headers) return self._do_request(request, validate_auth=validate_auth) - def post(self, path, data=None, headers={}, validate_auth=True): + def post(self, path, data=None, headers={}, validate_auth=True, query_params: dict[str, str] = None): url = urllib.parse.urljoin(self.url, urllib.parse.quote(path)) + if query_params: + url += "?" + urllib.parse.urlencode(query_params) if headers.get("Content-Type", None) == "application/json": data = json.dumps(data, cls=DateTimeEncoder).encode("utf-8") request = urllib.request.Request(url, data, headers, method="POST") From f4363c28eadfc583ed6bb912dd5a0a647ff420ab Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Wed, 6 Aug 2025 13:16:36 +0200 Subject: [PATCH 2/6] fix sending logs using POST method --- mergin/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mergin/client.py b/mergin/client.py index 46049311..9c0ccc52 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -1422,7 +1422,7 @@ def send_logs( if is_version_acceptable(self.server_version(), "2025.4.1") and ( diagnostic_logs_url is None or diagnostic_logs_url == "" ): - url = "v2/diagnostic-logs" + "?" + urllib.parse.urlencode(params) + url = "v2/diagnostic-logs" use_server_api = True else: if diagnostic_logs_url: @@ -1456,7 +1456,7 @@ def send_logs( header = {"content-type": "text/plain"} if use_server_api: - return self.post(url, data=payload, headers=header) + return self.post(url, data=payload, headers=header, query_params=params) else: request = urllib.request.Request(url, data=payload, headers=header) return self._do_request(request) From 3c1c18d9c6801ba049f48183614d44fbbae00d64 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 7 Aug 2025 08:37:46 +0200 Subject: [PATCH 3/6] convert file size to int() --- mergin/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mergin/client.py b/mergin/client.py index 9c0ccc52..625ddd7b 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -1437,8 +1437,8 @@ def send_logs( ) # We send more from the local logs - global_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.2 - local_logs_file_size_to_send = MAX_LOG_FILE_SIZE_TO_SEND * 0.8 + global_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.2) + local_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.8) global_logs = b"" if global_log_file and os.path.exists(global_log_file): From 69ce0d4d47940e994a8433e397be5d126acae900 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 7 Aug 2025 09:21:34 +0200 Subject: [PATCH 4/6] lower the sizes a bit --- mergin/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mergin/client.py b/mergin/client.py index 625ddd7b..7951d480 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -1437,8 +1437,8 @@ def send_logs( ) # We send more from the local logs - global_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.2) - local_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.8) + global_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.15) + local_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.75) global_logs = b"" if global_log_file and os.path.exists(global_log_file): From ed52fc8052f819ba54bd9586905e1921c92c6556 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 7 Aug 2025 13:33:05 +0200 Subject: [PATCH 5/6] lower log size to 5 mega --- mergin/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mergin/common.py b/mergin/common.py index a0b47604..b27c95ec 100644 --- a/mergin/common.py +++ b/mergin/common.py @@ -7,7 +7,7 @@ UPLOAD_CHUNK_SIZE = 10 * 1024 * 1024 # size of the log file part to send (if file is larger only this size from end will be sent) -MAX_LOG_FILE_SIZE_TO_SEND = 8 * 1024 * 1024 +MAX_LOG_FILE_SIZE_TO_SEND = 5 * 1024 * 1024 # default URL for submitting logs MERGIN_DEFAULT_LOGS_URL = "https://g4pfq226j0.execute-api.eu-west-1.amazonaws.com/mergin_client_log_submit" From 6dd35cde4eced6c9c9808333b792d0371dbb7001 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Thu, 7 Aug 2025 13:33:20 +0200 Subject: [PATCH 6/6] return split 0.2 / 0.8 --- mergin/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mergin/client.py b/mergin/client.py index 7951d480..625ddd7b 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -1437,8 +1437,8 @@ def send_logs( ) # We send more from the local logs - global_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.15) - local_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.75) + global_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.2) + local_logs_file_size_to_send = int(MAX_LOG_FILE_SIZE_TO_SEND * 0.8) global_logs = b"" if global_log_file and os.path.exists(global_log_file):