Webhook does work well what is the matter

i get this form error log

  File "apps/frappe/frappe/utils/background_jobs.py", line 220, in execute_job
    retval = method(**kwargs)
      site = 'accounting.test.site'
      method = <function enqueue_webhook at 0x7100507e0e50>
      event = None
      job_name = 'frappe.integrations.doctype.webhook.webhook.enqueue_webhook'
      kwargs = {'doc': <SalesInvoice: 2024-19709 docstatus=1>, 'webhook': {'name': 'test api 3', 'condition': 'doc.workflow_state in ["Submit", "Rejected"]', 'webhook_docevent': 'on_change', 'webhook_doctype': 'Sales Invoice', 'background_jobs_queue': None}}
      user = 'ali_aziz@lpg.com'
      is_async = True
      retry = 0
      retval = None
      method_name = 'frappe.integrations.doctype.webhook.webhook.enqueue_webhook'
      before_job_task = 'frappe.monitor.start'
  File "apps/frappe/frappe/integrations/doctype/webhook/webhook.py", line 192, in enqueue_webhook
    frappe.logger().debug({"webhook_error": e, "try": i + 1})
      doc = <SalesInvoice: 709 docstatus=1>
      webhook = <Webhook: test api 3>
      request_url = 'http://172.16.20.10/api/FinancialSystemApi/ConfirmUnload'
      headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6Ik-FinancialSystemApi'}
      data = {'InvoiceId': '709', 'Status': 'Submit', 'UserName': 'ali@i.com'}
      r = <Response [200]>
      i = 0
  File "apps/frappe/frappe/__init__.py", line 2348, in logger
    return get_logger(
      module = None
      with_more_info = False
      allow_site = True
      filter = None
      max_size = 100000
      file_count = 20
      get_logger = <function get_logger at 0x71004fb1dcf0>
  File "apps/frappe/frappe/utils/logger.py", line 75, in get_logger
    site_handler = RotatingFileHandler(sitelog_filename, maxBytes=max_size, backupCount=file_count)
      module = 'frappe'
      with_more_info = True
      allow_site = True
      filter = None
      max_size = 100000
      file_count = 20
      stream_only = None
      site = 'accounting.test.site'
      logger_name = 'None-accounting.test.site'
      logfile = 'frappe.log'
      log_filename = '../logs/frappe.log'
      logger = <Logger None-accounting.test.site (ERROR)>
      formatter = <logging.Formatter object at 0x71004d44b8b0>
      handler = <RotatingFileHandler logs/frappe.log (NOTSET)>
      sitelog_filename = 'accounting.test.site/logs/frappe.log'
  File "/usr/lib/python3.10/logging/handlers.py", line 155, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding,
      self = <exception while printing> Traceback (most recent call last):
          File "env/lib/python3.10/site-packages/traceback_with_variables/core.py", line 222, in _to_cropped_str
            raw = print_(obj)
          File "/usr/lib/python3.10/logging/__init__.py", line 1221, in __repr__
            level = getLevelName(self.level)
        AttributeError: 'RotatingFileHandler' object has no attribute 'level'
        
      filename = 'accounting.test.site/logs/frappe.log'
      mode = 'a'
      maxBytes = 100000
      backupCount = 20
      encoding = 'locale'
      delay = False
      errors = None
  File "/usr/lib/python3.10/logging/handlers.py", line 58, in __init__
    logging.FileHandler.__init__(self, filename, mode=mode,
      self = <exception while printing> Traceback (most recent call last):
          File "env/lib/python3.10/site-packages/traceback_with_variables/core.py", line 222, in _to_cropped_str
            raw = print_(obj)
          File "/usr/lib/python3.10/logging/__init__.py", line 1221, in __repr__
            level = getLevelName(self.level)
        AttributeError: 'RotatingFileHandler' object has no attribute 'level'
        
      filename = 'accounting.test.site/logs/frappe.log'
      mode = 'a'
      encoding = 'locale'
      delay = False
      errors = None
  File "/usr/lib/python3.10/logging/__init__.py", line 1169, in __init__
    StreamHandler.__init__(self, self._open())
      self = <exception while printing> Traceback (most recent call last):
          File "env/lib/python3.10/site-packages/traceback_with_variables/core.py", line 222, in _to_cropped_str
            raw = print_(obj)
          File "/usr/lib/python3.10/logging/__init__.py", line 1221, in __repr__
            level = getLevelName(self.level)
        AttributeError: 'RotatingFileHandler' object has no attribute 'level'
        
      filename = 'accounting.test.site/logs/frappe.log'
      mode = 'a'
      encoding = 'locale'
      delay = False
      errors = None
  File "/usr/lib/python3.10/logging/__init__.py", line 1201, in _open
    return open_func(self.baseFilename, self.mode,
      self = <exception while printing> Traceback (most recent call last):
          File "env/lib/python3.10/site-packages/traceback_with_variables/core.py", line 222, in _to_cropped_str
            raw = print_(obj)
          File "/usr/lib/python3.10/logging/__init__.py", line 1221, in __repr__
            level = getLevelName(self.level)
        AttributeError: 'RotatingFileHandler' object has no attribute 'level'
        
      open_func = <built-in function open>
builtins.PermissionError: [Errno 13] Permission denied: 'sites/accounting.test.site/logs/frappe.log'

This is the permission error. Make sure your frappe directory has the right to perform actions.

chmod -R o+rx /home/{your user name here}

any user do you mean?
user appear in error or any user do you mean?!

What does that mean? This is simple a permission error that you have to resolve this by using the user that you have created during the installation of the Frappe Bench. Use that user to make changes to the permissions of the bench directory.

it is secure that
i will gave the permission to any user to write in this file?
@maslamhmt


i get these error

The issue discussed involves a permission error when working with Frappe webhooks. The error arises due to insufficient rights for the user to write to the log file. To resolve it, the user must grant appropriate permissions to the Frappe directory. The solution involves using the user account created during the installation of Frappe Bench and modifying directory permissions accordingly.

You can view the full discussion here.

1 Like