Skip to content

Commit 5d36524

Browse files
authored
Merge pull request #21716 from mvdbeek/fix-collection-error-import-export
[25.1] Fix collection job state not preserved during history export/import
2 parents aeb29f9 + 493cb18 commit 5d36524

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/galaxy/model/store/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,9 @@ def _connect_job_io(
18211821
output_hdca = _find_hdca(output_key)
18221822
if output_hdca:
18231823
imported_job.add_output_dataset_collection(output_name, output_hdca)
1824+
# Also set the HDCA's job reference so job_state_summary works
1825+
if output_hdca.job_id is None:
1826+
output_hdca.job = imported_job
18241827

18251828
def _normalize_job_parameters(
18261829
self,
@@ -2240,12 +2243,10 @@ def export_history(
22402243
collections = sa_session.scalars(stmt_hdca)
22412244

22422245
for collection in collections:
2243-
# filter this ?
2246+
# Skip unpopulated collections (they don't have all elements yet),
2247+
# but export all others regardless of state to preserve error states
22442248
if not collection.populated:
2245-
break
2246-
if collection.state != "ok":
2247-
break
2248-
2249+
continue
22492250
self.export_collection(collection, include_deleted=include_deleted)
22502251

22512252
# Write datasets' attributes to file.

lib/galaxy_test/api/test_histories.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,18 @@ def check_failed(hda_or_job):
729729
history_id=imported_history_id, hid=1, assert_ok=False, hda_checker=check_failed, job_checker=check_failed
730730
)
731731

732+
# Also check collection state is preserved - regression test for issue #20450
733+
imported_collection = self.dataset_populator.get_history_collection_details(
734+
history_id=imported_history_id,
735+
history_content_type="dataset_collection",
736+
assert_ok=False,
737+
)
738+
assert "job_state_summary" in imported_collection, imported_collection
739+
assert imported_collection["job_state_summary"].get("error", 0) == 1, (
740+
f"Expected error count of 1 after import, got {imported_collection['job_state_summary']}. "
741+
"Collection job state was not preserved during history export/import (issue #20450)."
742+
)
743+
732744
def test_import_metadata_regeneration(self):
733745
if self.task_based:
734746
raise SkipTest("skipping test_import_metadata_regeneration for task based...")

0 commit comments

Comments
 (0)