diff --git a/.github/workflows/api.yaml b/.github/workflows/api.yaml index 4bd03e5bde5..0aafad578de 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api.yaml @@ -2,6 +2,7 @@ name: API tests on: [push, pull_request] env: GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' concurrency: group: api-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/api_paste.yaml b/.github/workflows/api_paste.yaml index bbde9dfe190..46cd18b4b71 100644 --- a/.github/workflows/api_paste.yaml +++ b/.github/workflows/api_paste.yaml @@ -3,6 +3,7 @@ on: [push, pull_request] env: GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' GALAXY_TEST_USE_UVICORN: false + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' concurrency: group: api-legacy-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/converter_tests.yaml b/.github/workflows/converter_tests.yaml index e01d907018e..a4363cc50b1 100644 --- a/.github/workflows/converter_tests.yaml +++ b/.github/workflows/converter_tests.yaml @@ -1,5 +1,7 @@ name: Converter tests on: [push, pull_request] +env: + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' concurrency: group: converter-${{ github.ref }} cancel-in-progress: true @@ -65,4 +67,4 @@ jobs: if: failure() with: name: Converter test results (${{ matrix.python-version }}) - path: tool_test_output.html \ No newline at end of file + path: tool_test_output.html diff --git a/.github/workflows/framework.yaml b/.github/workflows/framework.yaml index 95a4ef40757..dc3340ac1c7 100644 --- a/.github/workflows/framework.yaml +++ b/.github/workflows/framework.yaml @@ -1,5 +1,7 @@ name: Framework tests on: [push, pull_request] +env: + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' concurrency: group: framework-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index c4290b4b79e..fc1dba19c51 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -6,6 +6,7 @@ concurrency: env: GALAXY_TEST_DBURI: 'postgresql://postgres:postgres@localhost:5432/galaxy?client_encoding=utf8' GALAXY_TEST_AMQP_URL: 'amqp://localhost:5672//' + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' jobs: test: name: Test diff --git a/.github/workflows/integration_selenium.yaml b/.github/workflows/integration_selenium.yaml index 0ed645ac5fe..f9e7d523b10 100644 --- a/.github/workflows/integration_selenium.yaml +++ b/.github/workflows/integration_selenium.yaml @@ -8,6 +8,7 @@ env: GALAXY_SKIP_CLIENT_BUILD: '0' GALAXY_TEST_SELENIUM_RETRIES: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' jobs: test: name: Test diff --git a/.github/workflows/selenium.yaml b/.github/workflows/selenium.yaml index ce87a3971b8..dcf3b64873a 100644 --- a/.github/workflows/selenium.yaml +++ b/.github/workflows/selenium.yaml @@ -8,6 +8,7 @@ env: GALAXY_TEST_SKIP_FLAKEY_TESTS_ON_ERROR: 'true' GALAXY_TEST_SELENIUM_RETRIES: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' jobs: test: name: Test diff --git a/.github/workflows/selenium_beta.yaml b/.github/workflows/selenium_beta.yaml index add65a0152d..00379e09353 100644 --- a/.github/workflows/selenium_beta.yaml +++ b/.github/workflows/selenium_beta.yaml @@ -6,6 +6,7 @@ env: GALAXY_TEST_SELENIUM_RETRIES: 1 GALAXY_TEST_SELENIUM_BETA_HISTORY: 1 YARN_INSTALL_OPTS: --frozen-lockfile + GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA: '1' jobs: test: name: Test diff --git a/lib/galaxy/model/base.py b/lib/galaxy/model/base.py index cdf95d4a7f4..1f38853ddf4 100644 --- a/lib/galaxy/model/base.py +++ b/lib/galaxy/model/base.py @@ -2,6 +2,7 @@ Shared model and mapping code between Galaxy and Tool Shed, trying to generalize to generic database connections. """ +import os import threading from contextvars import ContextVar from inspect import ( @@ -108,6 +109,18 @@ def versioned_objects(iter): yield obj +def versioned_objects_strict(iter): + for obj in iter: + if hasattr(obj, '__create_version__'): + if not obj.history and not obj.history_id and obj.extension != 'len': + raise Exception(f'HistoryDatsetAssociation {obj} without history detected, this is not valid') + yield obj + + +if os.environ.get("GALAXY_TEST_RAISE_EXCEPTION_ON_HISTORYLESS_HDA"): + versioned_objects = versioned_objects_strict # noqa: F811 + + def versioned_session(session): @event.listens_for(session, 'before_flush') def before_flush(session, flush_context, instances):