Skip to content

Permisson Error /api/method/crm.api.doc.get_data #1453

@eis-qazi

Description

@eis-qazi

Describe the bug
I have freshly installed CRM (other packes are frappe and ERPNext and HRM)
I get this error when i use Vue front end to create Lead. It doesn't creates the lead in the backend. In console i get this error

ViewControls.vue:543 
 POST https://mywebsite.com/api/method/crm.api.doc.get_data 403 (FORBIDDEN)

frappeRequest.js:77 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 121, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 63, 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 1127, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 36, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/crm/crm/api/doc.py", line 557, in get_data
    "total_count": frappe.get_list(doctype, filters=filters, fields="count(*) as total_count")[
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1360, in get_list
    return frappe.model.qb_query.DatabaseQuery(doctype).execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/qb_query.py", line 195, in execute
    query = frappe.qb.get_query(**kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/query_builder/utils.py", line 65, in get_query
    return Engine().get_query(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/query.py", line 223, in get_query
    self.apply_fields(fields)
  File "apps/frappe/frappe/database/query.py", line 261, in apply_fields
    self.fields = self.parse_fields(fields)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/query.py", line 903, in parse_fields
    if sanitized_item := _sanitize_field(item.strip(), self.is_mariadb).strip():
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/query.py", line 1863, in _sanitize_field
    _validate_select_field(field)
  File "apps/frappe/frappe/database/query.py", line 1852, in _validate_select_field
    frappe.throw(
  File "apps/frappe/frappe/utils/messages.py", line 145, in throw
    msgprint(
  File "apps/frappe/frappe/utils/messages.py", line 106, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/utils/messages.py", line 57, in _raise_exception
    raise exc
frappe.exceptions.PermissionError: Invalid field format for SELECT: count(*) as total_count. Field names must be simple, backticked, table-qualified, aliased, or '*'.

frappeRequest.js:81 Uncaught (in promise) Error: /api/method/crm.api.doc.get_data PermissionError
    at Object.transformResponse (frappeRequest.js:81:17)
    at async Proxy.o (resources.js:103:18)

Expected behavior
The permisson i have had, as from backend i can still create leads, but not from Vue frontend of CRM

Desktop (please complete the following information):
Ubuntu
Frappe Framework: v15.x.x-develop (2455800) (develop)
ERPNext: v15.x.x-develop (48783d1) (develop)
Frappe HR: v16.0.0-dev (develop)
Frappe CRM: v2.0.0-dev (develop)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions