Skip to content

Fixed illegal argument exception in indices.py as request_timeout is expected instead of timeout. #937

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

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

jubins
Copy link
Contributor

@jubins jubins commented Apr 26, 2019

Whenever the user passes timeout parameter as mentioned in docstring an illegal argument exception is thrown. For the following methods in elasticsearch.client.indices.py, renamed this to expected request_timeout param in the decorator and docstring.

  1. create
  2. open
  3. close
  4. delete
  5. put_mapping
  6. put_alias
  7. update_aliases
  8. delete_alias
  9. put_template
  10. delete_template
  11. shrink
  12. rollover

…expected instead of timeout.

The `timeout` parameter in docstring is misleading for following methods in elasticsearch.client.indices.py, renamed this param in query_params decorator and docstring to `request_timeout`:

1. create
2. open
3. close
4. delete
5. put_mapping
6. put_alias
7. update_aliases
8. delete_alias
9. put_template
10. delete_template
11. shrink
12. rollover
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@fxdgear
Copy link
Contributor

fxdgear commented Apr 26, 2019

jenkins test this please

@jubins
Copy link
Contributor Author

jubins commented Apr 26, 2019

@fxdgear Saw some connection related failures for the test ES 6.6.2 and python 2.7. Tested in my local and seems to be working

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import elasticsearch as es
>>> es.__version__
(6, 3, 0)
>>> conn = es.Elasticsearch()
>>> conn.indices.exists('test_index')
False
>>> conn.indices.create('test_index', params={'request_timeout': 0.5})
{u'index': u'test_index', u'acknowledged': True, u'shards_acknowledged': True}
>>> conn.indices.exists('test_index')
True
>>> conn.indices.delete('test_index', params={'request_timeout': 1})
{u'acknowledged': True}
>>> conn.indices.exists('test_index')
False

>>> # Below test should error out, due to timeout parameter
>>> conn.indices.create('test_index', params={'timeout': 0.5})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jubin/.local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/jubin/.local/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 91, in create
    params=params, body=body)
  File "/home/jubin/.local/lib/python2.7/site-packages/elasticsearch/transport.py", line 318, in perform_request
    status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
  File "/home/jubin/.local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 185, in perform_request
    self._raise_error(response.status, raw_data)
  File "/home/jubin/.local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, u'illegal_argument_exception', u'failed to parse setting [timeout] with value [0.5] as a time value: unit is missing or unrecognized')
>>> 

@fxdgear
Copy link
Contributor

fxdgear commented Apr 26, 2019

jenkins retest this please

@jubins
Copy link
Contributor Author

jubins commented Apr 29, 2019

@fxdgear Hi, if all looks ok can this be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants