Skip to content

bug: Connection Error while generating a Report results in uploading a non-existing document #291

@DRMPN

Description

@DRMPN

Description

During execution via OSA.Web, the internal OSA Tool encountered an unhandled failure when attempting to access an LLM via API during the "Generate Report" step. Instead of aborting the workflow, the process incorrectly proceeded to the "Upload Report" step—despite no report being generated. This resulted in an invalid state and downstreamed errors.

Proposed fix

Wrap the LLM API call and report generation in a try-catch block.
On failure, log the error and explicitly cancel the workflow step.
Before uploading, verify the report file exists and is valid.

Log

[15:04:30] INFO     [15:04:30] - Output path changed to /var/essdata/tmp/tmpl_qflfhh                                                                                                           run.py:66
INFO     [15:04:30] - Config successfully updated and loaded                                                                                                                       run.py:335
[15:04:31] INFO     [15:04:31] - Successfully fetched GitHub metadata for repository: 'Roman223/GAN_MFS'                                                                                 metadata.py:255
INFO     [15:04:31] - GitHub repository 'Roman223/GAN_MFS' is already starred.                                                                                               git_agent.py:249
INFO     [15:04:31] - GitHub fork created successfully: https://github.com/osa-bot/GAN_MFS                                                                                   git_agent.py:107
INFO     [15:04:31] - Cloning the 'main' branch from https://github.com/Roman223/GAN_MFS into directory /var/essdata/tmp/tmpl_qflfhh/GAN_MFS...                              git_agent.py:344
[15:04:32] INFO     [15:04:32] - Cloning completed                                                                                                                                      git_agent.py:353
INFO     [15:04:32] - Basic mode selected for task scheduler.                                                                                                                 scheduler.py:60
INFO     [15:04:32] - Web mode enabled, returning plan for web interface.                                                                                                     scheduler.py:92
INFO     [15:04:32] - Creating and switching to branch osa_tool...                                                                                                           git_agent.py:382
INFO     [15:04:32] - Switched to branch osa_tool.                                                                                                                           git_agent.py:384
────────────────────────────────────────────────────────────────────────────────────────── Report generation ───────────────────────────────────────────────────────────────────────────────────────────
INFO     [15:04:32] - Starting analysis for repository Roman223/GAN_MFS                                                                                                   report_maker.py:349
ERROR    [15:04:32] - Error while building PDF report, HTTPConnectionPool(host='10.32.15.21', port=6672): Max retries exceeded with url: /chat_completion (Caused by      report_maker.py:370
NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f90d7ea6150>: Failed to establish a new connection: [Errno 111] Connection refused'))
Traceback (most recent call last):
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 787, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 493, in _make_request
conn.request(
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connection.py", line 445, in request
self.endheaders()
File "/usr/lib/python3.12/http/client.py", line 1333, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)

File "/usr/lib/python3.12/http/client.py", line 1093, in _send_output
self.send(msg)
File "/usr/lib/python3.12/http/client.py", line 1037, in send
self.connect()
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connection.py", line 276, in connect
self.sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connection.py", line 213, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f90d7ea6150>: Failed to establish a new connection: [Errno 111]
Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/connectionpool.py", line 841, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='10.32.15.21', port=6672): Max retries exceeded with url: /chat_completion (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f90d7ea6150>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/osa_tool/analytics/report_maker.py", line 364, in build_pdf
*self.body_second_part(),
^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/osa_tool/analytics/report_maker.py", line 275, in body_second_part
parsed_report = self.text_generator.make_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/osa_tool/analytics/report_generator.py", line 34, in make_request
response = self.model_handler.send_request(self._build_prompt())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/osa_tool/models/models.py", line 165, in send_request
response = self.client.invoke(messages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/protollm/connectors/rest_server.py", line 148, in invoke
response = super().invoke(messages, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 393, in invoke
self.generate_prompt(
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 1019, in generate_prompt
return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 837, in generate
self._generate_with_cache(
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 1085, in _generate_with_cache
result = self._generate(
^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/protollm/connectors/rest_server.py", line 131, in _generate
response = self._create_chat(messages, stop, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/protollm/connectors/rest_server.py", line 101, in _create_chat
response = requests.post(
^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/essdata/OSA.Web/venv/lib/python3.12/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.32.15.21', port=6672): Max retries exceeded with url: /chat_completion (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f90d7ea6150>: Failed to establish a new connection: [Errno 111] Connection refused'))
INFO     [15:04:32] - Uploading report...                                                                                                                                    git_agent.py:612
ERROR    [15:04:32] - Error: [Errno 2] No such file or directory: '/var/essdata/tmp/tmpl_qflfhh/GAN_MFS_report.pdf'                                                                run.py:179

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions