sailpoint-oss / python-sdk

MIT License
6 stars 3 forks source link

[Bug] Search ordered by created date fails on data format check #15

Closed rob-buskens-sp closed 1 week ago

rob-buskens-sp commented 6 months ago

Expectation: Sorted by created date, ascending or descending should return the results sorted in that order.

Code sample

search = sailpoint.v3.Search(
    indices=['events'], 
    query=sailpoint.v3.Query(query=f'created:>now-2d AND attributes.interface.exact:/Attribute Syn.+/ AND (attributes.appId:{source_id} OR attributes.sourceName.exact:"{source_name}")'), 
    sort=['-created']
)

search_documents = Paginator.paginate_search(sailpoint.v3.SearchApi(v3_client), search, increment=250, limit=100)

Traceback:

Traceback (most recent call last):
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/attribute_sync.py", line 63, in <module>
    search_documents = Paginator.paginate_search(sailpoint.v3.SearchApi(v3_client), search, increment=250, limit=10000)
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/sailpoint/paginator.py", line 64, in paginate_search
    results = search_api.search_post(search, None, increment)
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/venv/lib/python3.9/site-packages/pydantic/validate_call_decorator.py", line 59, in wrapper_function
    return validate_call_wrapper(*args, **kwargs)
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/venv/lib/python3.9/site-packages/pydantic/_internal/_validate_call.py", line 81, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/sailpoint/v3/api/search_api.py", line 1050, in search_post
    return self.api_client.response_deserialize(
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/sailpoint/v3/api_client.py", line 319, in response_deserialize
    raise ApiException.from_response(
  File "/Users/rob.buskens/Documents/GitHub/python-sdk/sailpoint/v3/exceptions.py", line 143, in from_response
    raise BadRequestException(http_resp=http_resp, body=body, data=data)
sailpoint.v3.exceptions.BadRequestException: (400)
Reason: 
HTTP response headers: HTTPHeaderDict({'Date': 'Sat, 25 May 2024 17:20:27 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '837', 'Connection': 'keep-alive', 'Server': 'nginx', 'Vary': 'Origin, Access-Control-Request-Method, Access-Control-Request-Headers', 'SLPT-Request-ID': '821a7bfba5634556b075321140d1f4bc', 'Access-Control-Expose-Headers': 'SLPT-Request-ID, Content-Type', 'X-Robots-Tag': 'noindex'})
HTTP response body: detail_code='400.1 Bad request content' tracking_id='821a7bfba5634556b075321140d1f4bc' messages=[ErrorMessageDto(locale='en-US', locale_origin=<LocaleOrigin.DEFAULT: 'DEFAULT'>, text='Your search query was invalid, reason: {"root_cause":{"reason":"failed to parse date field [2024-05-24 18:03:14.375000+00:00] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [2024-05-24 18:03:14.375000+00:00] with format [strict_date_optional_time||epoch_millis]]"}}.'), ErrorMessageDto(locale='und', locale_origin=<LocaleOrigin.REQUEST: 'REQUEST'>, text='Your search query was invalid, reason: {"root_cause":{"reason":"failed to parse date field [2024-05-24 18:03:14.375000+00:00] with format [strict_date_optional_time||epoch_millis]: [failed to parse date field [2024-05-24 18:03:14.375000+00:00] with format [strict_date_optional_time||epoch_millis]]"}}.')] causes=[]
rob-buskens-sp commented 1 week ago

Tried this recently with the most recent python SDK: 1.1.9 Now works as expected