From 903d25763f57705545223bc986b51816889063d7 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 29 Oct 2025 14:00:02 -0400 Subject: [PATCH] Fix AttributeError by storing ItemSource objects in default_item_source Previously, default_item_source was set to a string ("s3" or "local"), but matching_source() tried to access default_item_source.name, causing: AttributeError: 'str' object has no attribute 'name' This bug occurred when source_name=None (single data source configuration) and has existed since the ItemSource interface was introduced in 2021. Changes: - Store the actual ItemSource object reference instead of string name - Assign to intermediate variables (s3_source, file_source) for clarity Fixes the error when viewing datasets with a single data source configured. --- cellxgene_gateway/gateway.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cellxgene_gateway/gateway.py b/cellxgene_gateway/gateway.py index 1e9017b..6420f95 100644 --- a/cellxgene_gateway/gateway.py +++ b/cellxgene_gateway/gateway.py @@ -98,15 +98,17 @@ def initialize_data_sources(): if cellxgene_bucket is not None: from cellxgene_gateway.items.s3.s3item_source import S3ItemSource - item_sources.append(S3ItemSource(cellxgene_bucket, name="s3")) - default_item_source = "s3" + s3_source = S3ItemSource(cellxgene_bucket, name="s3") + item_sources.append(s3_source) + default_item_source = s3_source logger.info("Initialized S3 data source") logger.debug(f"S3 bucket: {cellxgene_bucket}") if cellxgene_data is not None: from cellxgene_gateway.items.file.fileitem_source import FileItemSource - item_sources.append(FileItemSource(cellxgene_data, name="local")) - default_item_source = "local" + file_source = FileItemSource(cellxgene_data, name="local") + item_sources.append(file_source) + default_item_source = file_source logger.info("Initialized local file data source") logger.debug(f"Data directory: {cellxgene_data}") if len(item_sources) == 0: