From 05e474e90ca0de00efcb6d1a3ac56e84df0bd067 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 10 Jul 2024 16:45:20 +0200 Subject: [PATCH] Check if dataset has any data at all before doing datatype-specific checks Fixes https://sentry.galaxyproject.org/share/issue/64d122b1f85748da9009b13ca82917c9/: ``` error: unpack requires a buffer of 4 bytes File "starlette/applications.py", line 123, in __call__ await self.middleware_stack(scope, receive, send) File "starlette/middleware/errors.py", line 186, in __call__ raise exc File "starlette/middleware/errors.py", line 164, in __call__ await self.app(scope, receive, _send) File "starlette_context/middleware/raw_middleware.py", line 92, in __call__ await self.app(scope, receive, send_wrapper) File "starlette/middleware/base.py", line 189, in __call__ with collapse_excgroups(): File "contextlib.py", line 155, in __exit__ self.gen.throw(typ, value, traceback) File "starlette/_utils.py", line 93, in collapse_excgroups raise exc File "starlette/middleware/base.py", line 191, in __call__ response = await self.dispatch_func(request, call_next) File "galaxy/webapps/galaxy/fast_app.py", line 109, in add_x_frame_options response = await call_next(request) File "starlette/middleware/base.py", line 165, in call_next raise app_exc File "starlette/middleware/base.py", line 151, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "starlette/middleware/exceptions.py", line 65, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "starlette/routing.py", line 756, in __call__ await self.middleware_stack(scope, receive, send) File "starlette/routing.py", line 776, in app await route.handle(scope, receive, send) File "starlette/routing.py", line 297, in handle await self.app(scope, receive, send) File "starlette/routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "starlette/routing.py", line 72, in app response = await func(request) File "fastapi/routing.py", line 278, in app raw_response = await run_endpoint_function( File "fastapi/routing.py", line 193, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File "starlette/concurrency.py", line 42, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) File "anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread return await future File "anyio/_backends/_asyncio.py", line 851, in run result = context.run(func, *args) File "galaxy/webapps/galaxy/api/datasets.py", line 446, in show return self.service.show(trans, dataset_id, hda_ldda, serialization_params, data_type, **extra_params) File "galaxy/webapps/galaxy/services/datasets.py", line 384, in show rval = self._converted_datasets_state( File "galaxy/webapps/galaxy/services/datasets.py", line 848, in _converted_datasets_state if not data_provider.has_data(chrom): File "galaxy/visualization/data_providers/genome.py", line 1185, in has_data f, bbi = self._get_dataset() File "galaxy/visualization/data_providers/genome.py", line 1319, in _get_dataset return f, BigWigFile(file=f) File "lib/bx/bbi/bigwig_file.pyx", line 174, in bx.bbi.bigwig_file.BigWigFile.__init__ File "lib/bx/bbi/bbi_file.pyx", line 129, in bx.bbi.bbi_file.BBIFile.__init__ File "lib/bx/bbi/bbi_file.pyx", line 139, in bx.bbi.bbi_file.BBIFile.open File "bx/misc/binary_file.py", line 42, in __init__ if struct.unpack(">I", bytes)[0] == magic: ``` --- lib/galaxy/webapps/galaxy/services/datasets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/galaxy/services/datasets.py b/lib/galaxy/webapps/galaxy/services/datasets.py index 87d4da9c537a..25dc26b5bb09 100644 --- a/lib/galaxy/webapps/galaxy/services/datasets.py +++ b/lib/galaxy/webapps/galaxy/services/datasets.py @@ -845,7 +845,7 @@ def _converted_datasets_state( data_provider = self.data_provider_registry.get_data_provider( trans, original_dataset=dataset, source="index" ) - if not data_provider.has_data(chrom): + if not dataset.has_data() or not data_provider.has_data(chrom): return dataset.conversion_messages.NO_DATA # Have data if we get here