elastic/elasticsearch-py

Tasks API failing with 8.17.1 (but not 8.15.2)

Closed this issue · 3 comments

Problem call:

        taskid = 'um92aFeET6uhTTztmds6QQ:1548121'
        response = None
        try:
            response = client.tasks.get(task_id=taskid)
        except Exception as err:
            msg = (
                f'Unable to obtain task information for task_id "{taskid}". '
                f'Response: {response} -- '
                f'Exception: {err}'
            )
            raise ValueError(msg) from err

This call works fine in 8.15.2. But attempting the same in 8.17.1 raises an unknown exception and warning:

Unable to obtain task information for task_id "um92aFeET6uhTTztmds6QQ:1548121". Response:
None -- Exception:
GeneralAvailabilityWarning('This API is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.')

Not sure what's going on, but something that was working no longer is. Affected versions may include any between 8.15.2 and 8.17.1.

Confirmed this also occurs in 8.16.0, so ostensibly every version between 8.16.0 and 8.17.1 is affected.

Hello @untergeek, and thanks for opening this issue! As mentioned in the release notes, elasticsearch-py 8.16.0 and above emit warnings for tech preview and beta APIs. We added this because we did not want users to rely on such APIs without knowing they were not GA yet. Indeed, as of Elasticsearch 8.17, the tasks APIs are still in tech preview.

However, the client code only emits a warning by using this decorator. Python allows turning warnings into exceptions, but it has to be explicitly configured to do so. The client is not doing this:

# Only raise one warning per deprecation message so as not
# to spam up the user if the same action is done multiple times.
warnings.simplefilter("default", category=ElasticsearchWarning, append=True)

(If it were error instead of default, it would raise an exception. See docs.python.org/3/library/warnings.html#the-warnings-filter for more details.) But pytest can override this setting, for example, and maybe python -Wall does it too? Not sure. In any case, I believe this issue is a duplicate of #2742.

Thank you for the context. This is indeed what I was bit by, but with it being the GeneralAvailabilityWarning instead.

The workaround in the release notes did the trick. This issue can be closed, or left open for others to find.