Skip to content

Lead Sync >> Internal server error #1516

@garazventures

Description

@garazventures

When we are adding all the details in the given field in Lead Sync Settings, there is an error showing "Internal Server Error" in the front end. When we are adding the same details to the backend of the New Lead Sync Source list there is the same error is showing with this.

There is an error output

App Versions

{
	"crm": "1.56.5",
	"email_delivery_service": "0.0.1",
	"frappe": "15.92.0"
}

Route

Form/Lead Sync Source/new-lead-sync-source-njebncbzjh

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 120, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 52, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 52, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1754, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 378, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 400, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 303, in insert
    self.run_method("before_insert")
  File "apps/frappe/frappe/model/document.py", line 1011, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1371, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1353, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1008, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/crm/crm/lead_syncing/doctype/lead_sync_source/lead_sync_source.py", line 51, in before_insert
    fetch_and_store_pages_from_facebook(self.access_token)
  File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/crm/crm/lead_syncing/doctype/lead_sync_source/facebook.py", line 156, in fetch_and_store_pages_from_facebook
    forms = fetch_and_store_leadgen_forms_from_facebook(page_id, page["access_token"])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/crm/crm/lead_syncing/doctype/lead_sync_source/facebook.py", line 187, in fetch_and_store_leadgen_forms_from_facebook
    forms = make_get_request(
            ^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/integrations/utils.py", line 39, in make_get_request
    return make_request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/integrations/utils.py", line 35, in make_request
    raise exc
  File "apps/frappe/frappe/integrations/utils.py", line 22, in make_request
    response.raise_for_status()
  File "env/lib/python3.11/site-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://graph.facebook.com/v23.0/901597873042752/leadgen_forms?access_token= ## access token from meta##  &fields=id%2Cname%2Cquestions&limit=15000

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Lead Sync Source\",\"name\":\"new-lead-sync-source-njebncbzjh\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"type\":\"Facebook\",\"enabled\":1,\"background_sync_frequency\":\"Every 5 Minutes\",\"access_token\":\"## access token from meta##  ",\"idx\":0}",
		"action": "Save"
	},
	"btn": {
		"jQuery3700170679232361833131": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 419,
						"namespace": ""
					}
				]
			}
		},
		"__sentry_instrumentation_handlers__": {
			"click": {
				"refCount": 1
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": "07cf1a36-ab1f-410c-957e-347379cb7a7a"
}

Response Data

{
	"exception": "requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://graph.facebook.com/v23.0/901597873042752/leadgen_forms?access_token=## access token from meta##  &fields=id%2Cname%2Cquestions&limit=15000",
	"exc_type": "HTTPError",
	"_exc_source": "crm (app)"
}

<img width="1898" height="852" alt="Image" src="https://github.com/user-attachments/assets/77200101-16c3-407c-89e1-7a0bae6ed538" />
<img width="1916" height="1027" alt="Image" src="https://github.com/user-attachments/assets/cb726b46-cf6c-493f-9983-6092af8f206a" />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions