Monkey patch customization - ignored path from hooks.py

Hello,
I have an easy monkey patch customization in hooks.py:

import frappe.integrations.utils
import js_utils.utils.utils

frappe.integrations.utils.make_request = js_utils.utils.utils.make_request_js

It is working perfect on devel custom ubuntu server.

But here is a problem on frappecloud server.

Patch works for standard doc event, but in scheduled event this patch is ignored and the original function is used.

Is it here any speciality for frappecloud server, please?

Jiri Sir

Hi @Jiri_Sir ,

Can you please explain which scheduled event you want to running this function. You monkey patch is absolutely correct. We have also written lots of monkey patches for clients but all monkey patches are running correctly in local server even also on a frappe cloud server.

Thank You !

Hi @Dhruvin-Bhaliya ,
thanks for quick replay.

I used it in the server script.

First has this setup:

  • Doctype Event
  • Before Save
  • Code

frappe.make_delete_request(f’https://graph.microsoft.com/v1.0/me/events/AQMkAG ', headers = headers, response_body = False)

When a I save the doc the monkey patch functions is called => Ok.

Second one:

  • Scheduled Event
  • Hourly
  • Code: the same as above.

When the second one is executed than here is this error in Scheduled Job Log:

Traceback (most recent call last):
File “apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 97, in execute
frappe.get_doc(“Server Script”, script_name).execute_scheduled_method()
File “apps/frappe/frappe/core/doctype/server_script/server_script.py”, line 117, in execute_scheduled_method
safe_exec(self.script)
File “apps/frappe/frappe/utils/safe_exec.py”, line 85, in safe_exec
exec(
File “”, line 22, in
File “apps/frappe/frappe/integrations/utils.py”, line 49, in make_delete_request
return make_request(“DELETE”, url, **kwargs)
TypeError: make_request() got an unexpected keyword argument ‘response_body’

Here I can find that the original path is used (apps/frappe/frappe/integrations/utils.py).

Maybe this is the issue of combinations: frappe cloud, server script and scheduled event.