From 772f24a300020b6e262f60bbfc3302abaf69ed7d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 01:00:04 +0000 Subject: [PATCH 1/4] fix gateway secret generation without federation checkout Co-authored-by: Lucas Parzianello --- gateway/scripts/generate-secrets.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gateway/scripts/generate-secrets.sh b/gateway/scripts/generate-secrets.sh index cdb74318..68cfbd1c 100755 --- a/gateway/scripts/generate-secrets.sh +++ b/gateway/scripts/generate-secrets.sh @@ -4,7 +4,10 @@ set -Eeuo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) GATEWAY_ROOT=$(cd "${SCRIPT_DIR}/.." && pwd) SDS_ROOT=$(cd "${GATEWAY_ROOT}/.." && pwd) -FEDERATION_ROOT=$(cd "${SDS_ROOT}/federation" && pwd) +FEDERATION_ROOT="" +if [[ -d "${SDS_ROOT}/federation" ]]; then + FEDERATION_ROOT=$(cd "${SDS_ROOT}/federation" && pwd) +fi SFS_ROOT=$(cd "${SDS_ROOT}/seaweedfs" && pwd) EXAMPLE_DIR="${GATEWAY_ROOT}/.envs/example" FEDERATION_SHARED_TEMPLATE="${SDS_ROOT}/federation-shared.example.env" @@ -271,8 +274,10 @@ function set_permissions() { env_dirs=( "${GATEWAY_ROOT}/.envs" "${SFS_ROOT}/.envs" - "${FEDERATION_ROOT}/.envs" ) + if [[ -n "${FEDERATION_ROOT}" ]]; then + env_dirs+=("${FEDERATION_ROOT}/.envs") + fi for dir in "${env_dirs[@]}"; do if [ -d "${dir}" ]; then find "${dir}" -type f -name "*.env" -exec chmod --changes 600 {} \; From 2ce1e89c71d624f51c702d50ff9896b3490c9a3d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 01:01:57 +0000 Subject: [PATCH 2/4] fix gateway pre-commit failures Co-authored-by: Lucas Parzianello --- .../api_methods/federation/compile_federated_data.py | 3 ++- .../api_methods/utils/asset_access_control.py | 4 ++-- gateway/sds_gateway/users/api/views.py | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gateway/sds_gateway/api_methods/federation/compile_federated_data.py b/gateway/sds_gateway/api_methods/federation/compile_federated_data.py index 9b8d567d..a0106625 100644 --- a/gateway/sds_gateway/api_methods/federation/compile_federated_data.py +++ b/gateway/sds_gateway/api_methods/federation/compile_federated_data.py @@ -100,7 +100,8 @@ def get_federated_export_doc_by_uuid( return None except os_exceptions.OpenSearchException as exc: log.warning( - f"Federation fed doc lookup failed for {asset_type.value} {asset_uuid}: {exc}", + f"Federation fed doc lookup failed for {asset_type.value} " + f"{asset_uuid}: {exc}", ) return None source = response.get("_source") diff --git a/gateway/sds_gateway/api_methods/utils/asset_access_control.py b/gateway/sds_gateway/api_methods/utils/asset_access_control.py index e736feac..0a9992b2 100644 --- a/gateway/sds_gateway/api_methods/utils/asset_access_control.py +++ b/gateway/sds_gateway/api_methods/utils/asset_access_control.py @@ -402,8 +402,8 @@ def disconnect_captures_from_dataset(dataset: Dataset) -> None: Capture.datasets.through.objects.filter(dataset_id=dataset.pk).delete() # TODO: remove FK after contraction Capture.objects.filter(dataset=dataset).update(dataset=None) - - reindex_captures_after_dataset_unlink(capture_pks) + + reindex_captures_after_dataset_unlink(capture_pks) def disconnect_assets(item: Dataset | Capture, item_type: ItemType) -> None: diff --git a/gateway/sds_gateway/users/api/views.py b/gateway/sds_gateway/users/api/views.py index 2f637d1f..283015ae 100644 --- a/gateway/sds_gateway/users/api/views.py +++ b/gateway/sds_gateway/users/api/views.py @@ -1,4 +1,5 @@ from collections.abc import Callable +from enum import StrEnum from typing import cast from django.conf import settings @@ -25,6 +26,7 @@ from .serializers import UserSerializer + class ServiceUserSetting(StrEnum): SVI_SERVER_EMAIL = "SVI_SERVER_EMAIL" FEDERATION_SYNC_USER_EMAIL = "FEDERATION_SYNC_USER_EMAIL" @@ -65,7 +67,7 @@ class BackendServiceMintAPIKeyView(APIView): def get(self, request: Request) -> Response: allowed_email = getattr(settings, self.service_user_email_setting) - + if not request.user.is_authenticated: return Response( {"error": "The requesting user could not be identified."}, @@ -80,7 +82,10 @@ def get(self, request: Request) -> Response: ) email_to_mint = "" - if self.service_user_email_setting == ServiceUserSetting.FEDERATION_SYNC_USER_EMAIL: + if ( + self.service_user_email_setting + == ServiceUserSetting.FEDERATION_SYNC_USER_EMAIL + ): email_to_mint = request_email elif self.service_user_email_setting == ServiceUserSetting.SVI_SERVER_EMAIL: email_to_mint = request.query_params.get("email") From 5f465f9245a1c69dce2f0190fb0c7ca272eb01fe Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 01:03:06 +0000 Subject: [PATCH 3/4] apply gateway hook formatting fixes Co-authored-by: Lucas Parzianello --- .../api_methods/federation/compile_federated_data.py | 6 ++---- .../sds_gateway/api_methods/utils/asset_access_control.py | 7 +++---- gateway/sds_gateway/users/api/views.py | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/gateway/sds_gateway/api_methods/federation/compile_federated_data.py b/gateway/sds_gateway/api_methods/federation/compile_federated_data.py index a0106625..c49d46b5 100644 --- a/gateway/sds_gateway/api_methods/federation/compile_federated_data.py +++ b/gateway/sds_gateway/api_methods/federation/compile_federated_data.py @@ -36,8 +36,7 @@ def federation_site_name() -> str: def capture_in_published_dataset(capture: Capture) -> bool: exportable_datasets = get_capture_datasets( - capture, - include_deleted=False + capture, include_deleted=False ).federation_exportable() return exportable_datasets.exists() @@ -48,8 +47,7 @@ def capture_in_other_published_datasets( exclude_dataset_id: UUID, ) -> bool: exportable_datasets = get_capture_datasets( - capture, - include_deleted=False + capture, include_deleted=False ).federation_exportable() return exportable_datasets.exclude(uuid=exclude_dataset_id).exists() diff --git a/gateway/sds_gateway/api_methods/utils/asset_access_control.py b/gateway/sds_gateway/api_methods/utils/asset_access_control.py index 0a9992b2..e785bb41 100644 --- a/gateway/sds_gateway/api_methods/utils/asset_access_control.py +++ b/gateway/sds_gateway/api_methods/utils/asset_access_control.py @@ -5,6 +5,9 @@ from django.db.models import Q from pydantic import UUID4 +from sds_gateway.api_methods.federation.reindex import ( + reindex_captures_after_dataset_unlink, +) from sds_gateway.api_methods.models import Capture from sds_gateway.api_methods.models import Dataset from sds_gateway.api_methods.models import File @@ -13,10 +16,6 @@ from sds_gateway.api_methods.models import user_has_access_to_item from sds_gateway.api_methods.utils import relationship_utils -from sds_gateway.api_methods.federation.reindex import ( - reindex_captures_after_dataset_unlink, -) - logger = logging.getLogger(__name__) diff --git a/gateway/sds_gateway/users/api/views.py b/gateway/sds_gateway/users/api/views.py index 283015ae..c6a3fb51 100644 --- a/gateway/sds_gateway/users/api/views.py +++ b/gateway/sds_gateway/users/api/views.py @@ -7,7 +7,6 @@ from django.http import HttpRequest from django.shortcuts import get_object_or_404 from drf_spectacular.utils import extend_schema -from loguru import logger as log from rest_framework import status from rest_framework.authentication import TokenAuthentication from rest_framework.decorators import action From a1e6cb8971e00fb70fb86461959f1a364ee2e546 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 01:03:54 +0000 Subject: [PATCH 4/4] apply federation import ordering fix Co-authored-by: Lucas Parzianello --- gateway/sds_gateway/api_methods/federation/reindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/sds_gateway/api_methods/federation/reindex.py b/gateway/sds_gateway/api_methods/federation/reindex.py index a89052ca..a292b50d 100644 --- a/gateway/sds_gateway/api_methods/federation/reindex.py +++ b/gateway/sds_gateway/api_methods/federation/reindex.py @@ -26,8 +26,8 @@ from sds_gateway.api_methods.models import Capture from sds_gateway.api_methods.models import Dataset from sds_gateway.api_methods.models import ItemType -from sds_gateway.api_methods.utils.relationship_utils import get_dataset_captures from sds_gateway.api_methods.utils.opensearch_client import get_opensearch_client +from sds_gateway.api_methods.utils.relationship_utils import get_dataset_captures if TYPE_CHECKING: from collections.abc import Iterable