You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
The search client should accept any valid datetime.
Actual behavior (describe the problem)
When submitting a search request that includes a datetime filter, if the datetime provided includes a tzinfo, the request will fail with the following error:
planet.exceptions.BadQuery: {"field": {"filter.config.0.config.gte": [{"message": "'2022-04-01T00:00:00+00:00Z' is not a 'date-time'"}]
I'm mostly concerned about how obtuse the actual error is - 2022-04-01T00:00:00+00:00Z is definitively a date-time, the added tzinfo just changes the formatting so that the API does not accept it as such. The client should either reject such datetimes before submitting the search, with a clearer error; or format them appropriately, such that the search is valid.
Related Issues #143 (although that one looks to be from V1)
Workaround
Don't include a tzinfo in datetimes
Minimum, Complete, Viable Code Sample
Configure your API key before running
fromdatetimeimportdatetimeimportpytzimportasynciofromplanetimportdata_filter, Sessionitem_type="PSScene"product_bundle="visual"# Add UTC timezone to TOIs:toi_start=datetime.fromisoformat("2022-04-01")
toi_end=datetime.fromisoformat("2022-04-28")
#Comment these two lines out and it'll work finetoi_start=toi_start.replace(tzinfo=pytz.UTC)
toi_end=toi_end.replace(tzinfo=pytz.UTC)
asyncdefmain():
asyncwithSession() assess:
search_filter=data_filter.date_range_filter("acquired", gte=toi_start, lte=toi_end)
ids= [i["id"] asyncforiinsess.client("data").search([item_type], search_filter, limit=10)]
print(f"""{len(ids)} scenes were found.""")
returnidsasyncio.run(main())
Environment Information
Operation System Information: MacOS 13.2.1
Python version: 3.9
Planet package version: 2.0rc2
Installation Method
pip
The text was updated successfully, but these errors were encountered:
Expected behavior
The search client should accept any valid datetime.
Actual behavior (describe the problem)
When submitting a search request that includes a datetime filter, if the datetime provided includes a tzinfo, the request will fail with the following error:
I'm mostly concerned about how obtuse the actual error is - 2022-04-01T00:00:00+00:00Z is definitively a date-time, the added tzinfo just changes the formatting so that the API does not accept it as such. The client should either reject such datetimes before submitting the search, with a clearer error; or format them appropriately, such that the search is valid.
Related Issues
#143 (although that one looks to be from V1)
Workaround
Don't include a tzinfo in datetimes
Minimum, Complete, Viable Code Sample
Configure your API key before running
Environment Information
Installation Method
The text was updated successfully, but these errors were encountered: