From 0c751d0e8a53ce45233f1ccae7bdc15d54c265ae Mon Sep 17 00:00:00 2001 From: bsatoriu Date: Wed, 25 Feb 2026 16:02:28 -0800 Subject: [PATCH 1/3] Refactor get_config function to improve host handling and logging --- api/endpoints/environment.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api/endpoints/environment.py b/api/endpoints/environment.py index a2199cb..d571834 100755 --- a/api/endpoints/environment.py +++ b/api/endpoints/environment.py @@ -1,6 +1,6 @@ import logging from flask_restx import Resource -from flask import request +from flask import request, current_app from api.restplus import api from urllib.parse import urlsplit from api import settings @@ -66,7 +66,7 @@ def get_config_from_api(api_host): def get_config(host, server_type): try: - ROOT = os.path.dirname(os.path.abspath(__file__)) + ROOT = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(ROOT, "environments.json")) as f: data = json.load(f) except FileNotFoundError: @@ -74,8 +74,15 @@ def get_config(host, server_type): logging.exception(msg) raise FileNotFoundError(msg) - base_url = "{0.netloc}".format(urlsplit(urllib.parse.unquote(host))) + unquoted_host = urllib.parse.unquote(host) + if "://" not in unquoted_host: + unquoted_host = "https://" + unquoted_host + base_url = "{0.netloc}".format(urlsplit(unquoted_host)) match = next((x for x in data if base_url == x[server_type]), None) + maap_config = next((x for x in data if x['default_host'] == True), None) if match is None else match + if match is None: + current_app.logger.debug("No environment.get_config() host match found, falling back to default_host config: %s", maap_config) + return maap_config From ae6b6f01880c6408490a765a12b7ffcc4719c100 Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 25 Feb 2026 17:46:24 -0800 Subject: [PATCH 2/3] set ops to default host --- api/endpoints/environments.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/endpoints/environments.json b/api/endpoints/environments.json index 92433be..17458af 100644 --- a/api/endpoints/environments.json +++ b/api/endpoints/environments.json @@ -7,7 +7,7 @@ "mas_server": "repo.dit.maap-project.org", "edsc_server": "ade.dit.maap-project.org:30052", "workspace_bucket": "maap-staging-workspace", - "default_host": true + "default_host": false }, { "environment": "uat", @@ -27,7 +27,7 @@ "mas_server": "mas.maap-project.org", "edsc_server": "ade.maap-project.org:30052", "workspace_bucket": "maap-ops-workspace", - "default_host": false + "default_host": true }, { "environment": "dit_2i2c", From 969e3fe3a8c66269177bf21619d8f170c476370d Mon Sep 17 00:00:00 2001 From: grallewellyn Date: Wed, 25 Feb 2026 19:47:41 -0800 Subject: [PATCH 3/3] reverted changes --- api/endpoints/environments.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/endpoints/environments.json b/api/endpoints/environments.json index 17458af..92433be 100644 --- a/api/endpoints/environments.json +++ b/api/endpoints/environments.json @@ -7,7 +7,7 @@ "mas_server": "repo.dit.maap-project.org", "edsc_server": "ade.dit.maap-project.org:30052", "workspace_bucket": "maap-staging-workspace", - "default_host": false + "default_host": true }, { "environment": "uat", @@ -27,7 +27,7 @@ "mas_server": "mas.maap-project.org", "edsc_server": "ade.maap-project.org:30052", "workspace_bucket": "maap-ops-workspace", - "default_host": true + "default_host": false }, { "environment": "dit_2i2c",