Skip to content

[Bug]: High Level Python SDK throws BadRequestException when referencing missing repository #7451

Open
@logan-hcg

Description

@logan-hcg

What happened?

What actually happened, including error codes if applies.

Steps to Reproduce:

import lakefs

lakefs.Repository("<not_real>").branch("branch-name").object("something").exists()

throws:

Traceback (most recent call last):
  File "<path>.venv/lib/python3.12/site-packages/lakefs/exceptions.py", line 139, in api_exception_handler
    yield
  File "<path>.venv/lib/python3.12/site-packages/lakefs/object.py", line 705, in exists
    self._client.sdk_client.objects_api.head_object(self._repo_id, self._ref_id, self._path)
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 40, in wrapper_function
    return vd.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 134, in call
    return self.execute(m)
           ^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 206, in execute
    return self.raw_function(**d, **var_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api/objects_api.py", line 922, in head_object
    return self.head_object_with_http_info(repository, ref, path, range, **kwargs)  # noqa: E501
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 40, in wrapper_function
    return vd.call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 134, in call
    return self.execute(m)
           ^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/pydantic/decorator.py", line 206, in execute
    return self.raw_function(**d, **var_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api/objects_api.py", line 1028, in head_object_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 407, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 222, in __call_api
    raise e
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 212, in __call_api
    response_data = self.request(
                    ^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/api_client.py", line 439, in request
    return self.rest_client.head_request(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/rest.py", line 251, in head_request
    return self.request("HEAD", url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<path>.venv/lib/python3.12/site-packages/lakefs_sdk/rest.py", line 223, in request
    raise BadRequestException(http_resp=r)
lakefs_sdk.exceptions.BadRequestException: (400)
Reason: Bad Request

Expected behavior

I would expect an exception to not be thrown, but instead return False (ie that the object does not exist)

lakeFS version

1.9.1

How lakeFS is installed

Kubernetes

Affected clients

Python lakefs client 0.3.0

Relevant log output

No response

Contact details

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions