diff --git a/lib/galaxy/datatypes/data.py b/lib/galaxy/datatypes/data.py
index be434cbcc3cd..cad936f06b16 100644
--- a/lib/galaxy/datatypes/data.py
+++ b/lib/galaxy/datatypes/data.py
@@ -337,10 +337,10 @@ def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
def display_peek(self, dataset: DatasetProtocol) -> str:
"""Create HTML table, used for displaying peek"""
+ if not dataset.peek:
+ return "Peek not available"
out = ['
']
try:
- if not dataset.peek:
- dataset.set_peek()
data = dataset.peek
lines = data.splitlines()
for line in lines:
diff --git a/lib/galaxy/datatypes/qiime2.py b/lib/galaxy/datatypes/qiime2.py
index cff199def66c..0b998bf69c5e 100644
--- a/lib/galaxy/datatypes/qiime2.py
+++ b/lib/galaxy/datatypes/qiime2.py
@@ -50,6 +50,10 @@ def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
dataset.peek = "\n".join(map(": ".join, self._peek(dataset)))
def display_peek(self, dataset: DatasetProtocol) -> str:
+ if dataset.metadata.semantic_type is None:
+ # Proxy for metadata elements not (yet) set
+ return "Peek unavailable"
+
def make_row(pair):
return f"{pair[0]} | {html.escape(pair[1])} |
"
diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py
index 53bd1e5faedb..34ce0c47937e 100644
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -4666,7 +4666,11 @@ def as_display_type(self, type, **kwd):
return self.datatype.as_display_type(self, type, **kwd)
def display_peek(self):
- return self.datatype.display_peek(self)
+ try:
+ return self.datatype.display_peek(self)
+ except Exception:
+ log.exception("Error occurred while generating dataset peek")
+ return None
def display_name(self):
return self.datatype.display_name(self)
diff --git a/test/unit/data/datatypes/test_qiime2.py b/test/unit/data/datatypes/test_qiime2.py
index 7dab355b0b75..8b57cf4431bc 100644
--- a/test/unit/data/datatypes/test_qiime2.py
+++ b/test/unit/data/datatypes/test_qiime2.py
@@ -38,6 +38,9 @@ def test_qza_set_peek():
with get_input_files("qiime2.qza") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])
+ dataset.metadata.semantic_type = None
+ dataset.metadata.uuid = None
+ assert qza.display_peek(dataset) == "Peek unavailable"
qza.set_meta(dataset)
qza.set_peek(dataset)