Skip to content

OME-TIFF: Result::unwrap() on an Err value: General("invalid utf-8 sequence of 1 bytes from index 2144") #101

Open
@weiji14

Description

@weiji14

FYI I decided to try the OME-TIFF file from https://www.cellimagelibrary.org/images/40613 and encountered another panic on opening (xref virtual-zarr/virtual-tiff#32).

Originally posted by @maxrjones in #97

Code to reproduce panic:

import asyncio
from async_tiff.store import HTTPStore

from async_tiff import TIFF

async def test_ome_tiff():
    store = HTTPStore(url="https://cildata.crbs.ucsd.edu/")
    path = "media/images/40613/40613.tif"

    tiff = await TIFF.open(path=path, store=store)
    return tiff

if __name__ == "__main__":
    asyncio.run(test_ome_tiff())

Full traceback:

thread 'tokio-runtime-worker' panicked at python/src/tiff.rs:42:18:
called `Result::unwrap()` on an `Err` value: General("invalid utf-8 sequence of 1 bytes from index 2144")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/user/projects/async-tiff/python/tests/test_ome_tiff.py", line 58, in <module>
    asyncio.run(test_ome_tiff())
  File "/home/user/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/user/Documents/github/async-tiff/python/tests/test_ome_tiff.py", line 49, in test_ome_tiff
    tiff = await TIFF.open(path=path, store=store)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_async_runtimes.RustPanic: rust future panicked: unknown error

Panic is caused by this .unwrap() here:

let ifds = metadata_reader
.read_all_ifds(&metadata_fetch)
.await
.unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions