Skip to content

BUG: IndexError in _datetime_from_weaviate_str when date property is unset (empty string) #2052

@devteamaegis

Description

@devteamaegis

What breaks

_datetime_from_weaviate_str in weaviate/util.py crashes with IndexError when passed an empty string. This is triggered in practice because the protobuf wire-format default for an unset string field is "", so any gRPC query response that includes an object with an unset date property will cause the client to crash during deserialization in base_executor.py.

Traceback

File "weaviate/util.py", line 754, in _datetime_from_weaviate_str
    if string[-1] != "Z":
       ~~~~~~^^^^
IndexError: string index out of range

Reproduce

from weaviate.util import _datetime_from_weaviate_str
_datetime_from_weaviate_str("")  # raises IndexError

Environment

weaviate-python-client v4.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions