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
I encountered an issue when using OpenSearch in my flask (gunicorn) project. It appears to be related to JSON parsing, resulting in a RequestError(400, 'json_parse_exception'). This error occurs when trying to execute a search query. Note that this error is not showing up each time and I am making always the same request.
Error Message:
Exception: RequestError(400, 'json_parse_exception', 'Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens\n at [Source: (org.opensearch.core.common.io.stream.InputStreamStreamInput); line: 1, column: 2]')
Traceback: Traceback (mostrecentcalllast):
File"/home/user/project/data-module/api/routes.py", line263, ingw_recv_account_detailsresponse=search_document(os_cli, OS_INDEX_IN, query)
File"/home/user/project/data-module/api/utils/opensearch.py", line32, insearch_documentresponse=os_cli.search(
File"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/client/utils.py", line179, in_wrappedreturnfunc(*args, params=params, headers=headers, **kwargs)
File"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/client/__init__.py", line1553, insearchreturnthis_transport.perform_request(
File"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/transport.py", line409, inperform_requestraiseeFile"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/transport.py", line370, inperform_requeststatus, headers_response, data=connection.perform_request(
File"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/connection/http_urllib3.py", line266, inperform_requestthis_transport._raise_error(
File"/home/user/anaconda3/lib/python3.9/site-packages/opensearchpy/connection/base.py", line301, in_raise_errorraiseHTTP_EXCEPTIONS.get(status_code, TransportError)(
opensearchpy.exceptions.RequestError: RequestError(400, 'json_parse_exception', 'Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens\n at [Source: (org.opensearch.core.common.io.stream.InputStreamStreamInput); line: 1, column: 2]')
Python Code:
# Function to search a document from an index.defsearch_document(os_cli, index, query):
response=os_cli.search(
index=index,
body=query
)
returnresponseOS_INDEX_IN=RISK_VALUES_IDXrequest_id=str(data_type_22['requestId']).encode('utf-8')
query= {
'query': {
'match': {'requestId': request_id.decode('utf-8')}
}
}
response=search_document(os_cli, OS_INDEX_IN, query)
Environment Details:
Operating System: Ubuntu 18.04
Python Version: 3.9.13
OpenSearch Version: 2.11
opensearch-py Version: 2.4.2
Thank you for your assistance in resolving this issue. Let me know if you need any more information from my end to address this problem.
The text was updated successfully, but these errors were encountered:
I believe this is opensearch-project/OpenSearch#10802 and it was fixed in 2.11.1. Can you please try that? Reopen if that didn't fix the problem please.
Description:
I encountered an issue when using OpenSearch in my flask (gunicorn) project. It appears to be related to JSON parsing, resulting in a
RequestError(400, 'json_parse_exception')
. This error occurs when trying to execute a search query. Note that this error is not showing up each time and I am making always the same request.Error Message:
Python Code:
Environment Details:
Thank you for your assistance in resolving this issue. Let me know if you need any more information from my end to address this problem.
The text was updated successfully, but these errors were encountered: