fix: ensure PR body is not None
Description
If the PR body is None
, we cannot parse it.
Supporting information
The error:
Traceback (most recent call last):
File "/home/app/function/handler.py", line 329, in handle
handler(body)
File "/home/app/function/handler.py", line 291, in handle_cron_invocation
list(executor.map(worker, open_pull_requests + closed_pull_requests))
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 619, in result_iterator
yield _result_or_cancel(fs.pop())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 317, in _result_or_cancel
return fut.result(timeout)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/function/handler.py", line 228, in __handle_state_change
return gitlab_client.trigger_instance_create_or_update_pipeline(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/function/gitlab.py", line 270, in trigger_instance_create_or_update_pipeline
"applied_settings": params.pull_request.extra_settings,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/function/github.py", line 71, in extra_settings
return self.__extract_from_body(r"[Ss]ettings", self.body) or ""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/function/github.py", line 120, in __extract_from_body
if match := re.search(pattern, body):
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/re/__init__.py", line 177, in search
return _compile(pattern, flags).search(string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
Testing instructions
Steps to test the changes:
- Deploy the changes to the axim sandbox cluster
- Trigger a new run
- Ensure this PR is picked up
Dependencies
NA
Screenshots
NA
Checklist
If any of the items below is not applicable, do not remove them, but put a check in it.
-
All providers include the new feature/change -
All affected providers can provision new clusters -
Unit tests are added/updated -
Documentation is added/updated -
The TOOLS_CONTAINER_IMAGE_VERSION
in ci_vars.yml is updated -
The grove-template repository is updated
Additional context
NA