Problem when I do a web request

Hello

I developed an application and one of the components allows to retrieve information from a gene on NCBI serious to a web request

I have never had any problems so far yet since today and without having modified much it works once out of 2
The request is not huge and I did a lot of testing. Before it worked very well with input tests and now with input tests it works once out of 2.

Here is the mistake I have.

2023-09-14 16:58:23.630 Uncaught app exception
Traceback (most recent call last):
File “/home/adminuser/venv/lib/python3.11/site-packages/requests/models.py”, line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/json/decoder.py”, line 353, in raw_decode
obj, end = self.scan_once(s, idx)
^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 95 (char 94)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 552, in _run_script
exec(code, module.dict)
File “/mount/src/tfinder/TFinder-v1.py”, line 108, in
allapp_page()
File “/mount/src/tfinder/navigation/allapp.py”, line 67, in allapp_page
aio_page()
File “/mount/src/tfinder/navigation/aio.py”, line 242, in aio_page
species).find_sequences()
^^^^^^^^^^^^^^^^
File “/mount/src/tfinder/tfinder/init.py”, line 87, in find_sequences
entrez_id = NCBIdna.convert_gene_to_entrez_id(self.gene_id, self.species)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/mount/src/tfinder/tfinder/init.py”, line 138, in convert_gene_to_entrez_id
response_data = response.json()
^^^^^^^^^^^^^^^
File “/home/adminuser/venv/lib/python3.11/site-packages/requests/models.py”, line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Invalid control character at: line 1 column 95 (char 94)

My code has always worked and I don’t think it comes from him because sometimes it works and sometimes it doesn’t.

Moreover when I test my orders locally I have no worries

If anyone has a solution :ok_hand:t3:

Thank you

Hey @Jumitti,

Thanks for sharing your question! Can you also share a runnable code snippet so we can reproduce this error?

problem solved

In fact, the website where I made the request had a part under maintenance. My request was correct and my request could be successful but the latency due to maintenance generated this error because sometimes the request was not successful.

Sorry for the inconvenience and thank you for your response and interest

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.