lakeFS
lakeFS copied to clipboard
[Bug]: LogCommits Since Parameter Format Mismatch in Python Client
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
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.
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.
Bad bot!