From 9e70bcf22620f0b7670c47fd542b77716517683a Mon Sep 17 00:00:00 2001 From: gpetrak Date: Tue, 7 Apr 2026 12:16:01 +0300 Subject: [PATCH 1/6] correctly build the service URL if no extra query is included --- geonode/upload/handlers/remote/wms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geonode/upload/handlers/remote/wms.py b/geonode/upload/handlers/remote/wms.py index 69bb444992a..a9a3efe7b53 100644 --- a/geonode/upload/handlers/remote/wms.py +++ b/geonode/upload/handlers/remote/wms.py @@ -77,7 +77,7 @@ def prepare_import(self, files, execution_id, **kwargs): _exec = orchestrator.get_execution_object(exec_id=execution_id) cleaned_url, _, _, _ = WmsServiceHandler.get_cleaned_url_params(_exec.input_params.get("url")) parsed_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" - ows_url = f"{parsed_url}?{cleaned_url.query}" + ows_url = f"{parsed_url}?{cleaned_url.query}" if cleaned_url.query else parsed_url to_update = { "ows_url": ows_url, "parsed_url": parsed_url, From 89ba794b4eb88dff5f60f8b8240fe9cf3ad2ec42 Mon Sep 17 00:00:00 2001 From: gpetrak Date: Tue, 7 Apr 2026 13:46:51 +0300 Subject: [PATCH 2/6] replace ows_url and parsed_url with base_url --- geonode/upload/handlers/remote/wms.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/geonode/upload/handlers/remote/wms.py b/geonode/upload/handlers/remote/wms.py index a9a3efe7b53..5b4e3155851 100644 --- a/geonode/upload/handlers/remote/wms.py +++ b/geonode/upload/handlers/remote/wms.py @@ -76,11 +76,14 @@ def prepare_import(self, files, execution_id, **kwargs): """ _exec = orchestrator.get_execution_object(exec_id=execution_id) cleaned_url, _, _, _ = WmsServiceHandler.get_cleaned_url_params(_exec.input_params.get("url")) - parsed_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" - ows_url = f"{parsed_url}?{cleaned_url.query}" if cleaned_url.query else parsed_url + + # This is the "Base URL" (e.g., https://domain/wms) + # We use this for BOTH to ensure the Harvester lookup succeeds. + base_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" + to_update = { - "ows_url": ows_url, - "parsed_url": parsed_url, + "ows_url": base_url, + "parsed_url": base_url, "remote_resource_id": _exec.input_params.get("identifier", None), } if _exec.input_params.get("parse_remote_metadata", False): From 057dd582b5d4c267b0b2467410fe979e9a22d3d2 Mon Sep 17 00:00:00 2001 From: gpetrak Date: Tue, 7 Apr 2026 13:53:59 +0300 Subject: [PATCH 3/6] fixing flake issues --- geonode/upload/handlers/remote/wms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geonode/upload/handlers/remote/wms.py b/geonode/upload/handlers/remote/wms.py index 5b4e3155851..5feed6d4f5b 100644 --- a/geonode/upload/handlers/remote/wms.py +++ b/geonode/upload/handlers/remote/wms.py @@ -79,7 +79,7 @@ def prepare_import(self, files, execution_id, **kwargs): # This is the "Base URL" (e.g., https://domain/wms) # We use this for BOTH to ensure the Harvester lookup succeeds. - base_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" + base_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" to_update = { "ows_url": base_url, From 4d8833a9a3ec13aa89c33b802c2a3af8e6374b58 Mon Sep 17 00:00:00 2001 From: gpetrak Date: Wed, 8 Apr 2026 12:35:25 +0300 Subject: [PATCH 4/6] use parsed_url and ows_url instead of the base_url --- geonode/upload/handlers/remote/wms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/geonode/upload/handlers/remote/wms.py b/geonode/upload/handlers/remote/wms.py index 5feed6d4f5b..8d4722084dc 100644 --- a/geonode/upload/handlers/remote/wms.py +++ b/geonode/upload/handlers/remote/wms.py @@ -77,13 +77,12 @@ def prepare_import(self, files, execution_id, **kwargs): _exec = orchestrator.get_execution_object(exec_id=execution_id) cleaned_url, _, _, _ = WmsServiceHandler.get_cleaned_url_params(_exec.input_params.get("url")) - # This is the "Base URL" (e.g., https://domain/wms) - # We use this for BOTH to ensure the Harvester lookup succeeds. - base_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" + parsed_url = f"{cleaned_url.scheme}://{cleaned_url.netloc}{cleaned_url.path}" + ows_url = cleaned_url._replace(params="", fragment="").geturl() to_update = { - "ows_url": base_url, - "parsed_url": base_url, + "ows_url": ows_url, + "parsed_url": parsed_url, "remote_resource_id": _exec.input_params.get("identifier", None), } if _exec.input_params.get("parse_remote_metadata", False): From 3e6791258f46b7c3c5bf488bfa77292752d7b7d0 Mon Sep 17 00:00:00 2001 From: gpetrak Date: Wed, 8 Apr 2026 15:32:08 +0300 Subject: [PATCH 5/6] fixing tests --- geonode/upload/handlers/remote/tests/test_wms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geonode/upload/handlers/remote/tests/test_wms.py b/geonode/upload/handlers/remote/tests/test_wms.py index 5435e849710..76b476c3f9c 100644 --- a/geonode/upload/handlers/remote/tests/test_wms.py +++ b/geonode/upload/handlers/remote/tests/test_wms.py @@ -17,6 +17,7 @@ # ######################################################################### from collections import namedtuple +from urllib.parse import ParseResult from django.test import TestCase from mock import MagicMock, patch from geonode.upload.api.exceptions import ImportException @@ -133,7 +134,7 @@ def test_prepare_import_should_not_update_the_execid(self, remote_wms): prepare_import should update the execid if the parse_remote_metadata is False """ - fake_url = MagicMock(shema="http", netloc="fake", path="foo", query="bar") + fake_url = ParseResult(scheme="http", netloc="fake", path="/foo", params="", query="bar", fragment="") remote_wms.get_cleaned_url_params.return_value = fake_url, None, None, None try: From 63f5403d2c19df34215589b5a3d04beeaf7451cb Mon Sep 17 00:00:00 2001 From: gpetrak Date: Wed, 8 Apr 2026 16:31:48 +0300 Subject: [PATCH 6/6] fixing tests --- geonode/upload/handlers/remote/tests/test_wms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geonode/upload/handlers/remote/tests/test_wms.py b/geonode/upload/handlers/remote/tests/test_wms.py index 76b476c3f9c..b21a243484b 100644 --- a/geonode/upload/handlers/remote/tests/test_wms.py +++ b/geonode/upload/handlers/remote/tests/test_wms.py @@ -166,7 +166,7 @@ def test_prepare_import_should_update_the_execid(self, get_wms_resource, remote_ if the parse_remote_metadata is True """ # remote_wms = MagicMock(title="updated_title", bbox=[1,2,3,4]) - fake_url = MagicMock(shema="http", netloc="fake", path="foo", query="bar") + fake_url = ParseResult(scheme="http", netloc="fake", path="/foo", params="", query="bar", fragment="") remote_wms.get_cleaned_url_params.return_value = fake_url, None, None, None obj = namedtuple("WmsObj", field_names=["title", "boundingBoxWGS84"])