Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: LogCommits Since Parameter Format Mismatch in Python Client #6970

Open
clintonmonk opened this issue Nov 9, 2023 · 3 comments
Open
Labels
bug Something isn't working contributor no stale Using this label will prevent items from being marked as stale

Comments

@clintonmonk
Copy link

clintonmonk commented Nov 9, 2023

What happened?

We are experiencing errors while trying to use the new since argument for log_commits using the Python lakefs_sdk client.

It appears there is a format mismatch between the Python client and the LakeFS API. Looking closer, the Python client uses the format string "%Y-%m-%dT%H:%M:%S.%f%z" which outputs values like "2023-05-09T09:53:33.853466". However, the API expects values like "2006-01-02T15:04:05Z07:00". As a result, the API returns an HTTP 400 Bad Request.

To reproduce:

from lakefs_sdk.client import LakeFSClient
from lakefs_sdk import Configuration
from datetime import datetime
from dateutil.relativedelta import relativedelta

configuration = Configuration(...)
lakefs_client = LakeFSClient(configuration)

six_months_ago = datetime.now() - relativedelta(months=6)

# this will result in an HTTP 400 
lakefs_client.refs_api.log_commits(
    "repo",
    "ref",
    objects=["path/to/object"],
    amount=1,
    since=six_months_ago,
    limit=True,
)

I tried passing my own string value (e.g. since="2023-11-09T10:00:00"), but it looks like the client converts the string into a datetime first anyway before then formatting it using its own format string.

As a workaround, I was able to successfully change the client's datetime format string. However, I'm not sure that this is the expected solution.

configuration = Configuration(...)
configuration.datetime_format = "%Y-%m-%dT%H:%M:%SZ"  # to match Go's time.RFC3339 format
lakefs_client = LakeFSClient(configuration)

...

Expected behavior

Expected behavior is that the Python client should be compatible with the API without me needing to configure the format string.

lakeFS version

LakeFS Cloud

How lakeFS is installed

Cloud

Affected clients

lakefs-sdk==1.1.0.2

Relevant log output

Bad Request: Invalid format for parameter since: error parsing '2023-05-09T10:13:29' as RFC3339 or 2006-01-02 time: parsing time \"2023-05-09T10:13:29\": extra text: \"T10:13:29\"\n"

Contact details

No response

@clintonmonk clintonmonk added bug Something isn't working contributor labels Nov 9, 2023
@nopcoder nopcoder self-assigned this Nov 12, 2023
@nopcoder
Copy link
Contributor

Didn't find a good solution by update the openapi generated python sdk code and the same from the lakeFS generated code side.
It seems python doesn't have a good way to produce strftime format that will match RFC-3339.

@nopcoder nopcoder removed their assignment Nov 20, 2023
Copy link

This issue is now marked as stale after 90 days of inactivity, and will be closed soon. To keep it, mark it with the "no stale" label.

@github-actions github-actions bot added the stale label Feb 19, 2024
@arielshaqed
Copy link
Contributor

Bad bot!

@arielshaqed arielshaqed added the no stale Using this label will prevent items from being marked as stale label Feb 19, 2024
@github-actions github-actions bot removed the stale label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributor no stale Using this label will prevent items from being marked as stale
Projects
None yet
Development

No branches or pull requests

3 participants