Skip to content

namespace_exists() / table_exists() throw RuntimeError instead of NamespaceNotFoundError / TableNotFoundError #6240

@jorritsandbrink

Description

@jorritsandbrink

As per their docstring, DirectoryNamespace.namespace_exists() and DirectoryNamespace.table_exists() are supposed to raise NamespaceNotFoundError / TableNotFoundError when the namespace/table does not exist, however, they return a RuntimeError with message "Failed to downcast NamespaceError source, falling back to runtime error. This may indicate a version mismatch.".

Repro:

import tempfile

from lance.namespace import DirectoryNamespace, NamespaceExistsRequest, TableExistsRequest


ns = DirectoryNamespace(root=tempfile.mkdtemp())
ns.namespace_exists(NamespaceExistsRequest(id=["nonexistent_namespace"]))
# ns.table_exists(TableExistsRequest(id=["nonexistent_table"]))

Result:

[2026-03-20T15:20:33Z WARN  lance::error] Failed to downcast NamespaceError source, falling back to runtime error. This may indicate a version mismatch. Source type: "Namespace 'nonexistent_namespace' not found"
Traceback (most recent call last):
  File "/home/j/repos/dlt-3546/tmp.py", line 7, in <module>
    ns.namespace_exists(NamespaceExistsRequest(id=["nonexistent_namespace"]))
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/j/.cache/uv/archive-v0/HiBtUgMOpG-E8F-FVIxL_/lib/python3.13/site-packages/lance/namespace.py", line 351, in namespace_exists
    self._inner.namespace_exists(request.model_dump())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Namespace error: Namespace 'nonexistent_namespace' not found, /home/runner/work/lance/lance/rust/lance-namespace-impls/src/dir/manifest.rs:1722:17

Using pylance==3.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions