The-Commit-Company / Raven

Simple, open source team messaging platform
https://thecommit.company/products/raven
GNU Affero General Public License v3.0
250 stars 87 forks source link

OperationalError /api/method/raven.api.raven_channel.get_all_channels (1054, "Unknown column 'tabUser.type' in 'field list'") #898

Closed ankush closed 2 months ago

ankush commented 2 months ago
OperationalError: (1054, "Unknown column 'tabUser.type' in 'field list'")
  File "frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
  File "frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "__init__.py", line 1761, in call
    return fn(*args, **newargs)
  File "frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "raven/api/raven_channel.py", line 44, in get_all_channels
    extra_users = get_extra_users(dm_list)
  File "raven/api/raven_channel.py", line 141, in get_extra_users
    return frappe.db.get_all(
  File "frappe/database/database.py", line 761, in get_all
    return frappe.get_all(*args, **kwargs)
  File "__init__.py", line 2050, in get_all
    return get_list(doctype, *args, **kwargs)
  File "__init__.py", line 2025, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
  File "frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
  File "frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
  File "frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
  File "pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
ankush commented 2 months ago

I dont know any details, this was caught in error logs

mohsinalimat commented 2 months ago

I am facing same issue.

mohsinalimat commented 2 months ago

When I disable desk from raven settings then. Issue is not coming.

nikkothari22 commented 2 months ago

Was fixed in fix: uncreated users alignment on sidebar . Will merge it to main

nikkothari22 commented 2 months ago

Should be fixed now. Pull the latest version from main.

mohsinalimat commented 2 months ago

Still issue appear with latest pull of raven develop branch.

Screenshot 2024-05-02 at 1 02 51 PM

App Versions

{
    "erpnext": "15.20.3",
    "frappe": "15.22.0",
    "hrms": "15.17.0",
    "payments": "0.0.1",
    "raven": "1.5.3"
}

Route

Form/Raven Settings/Raven Settings

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, 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 1718, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/raven/raven/api/raven_channel.py", line 44, in get_all_channels
    extra_users = get_extra_users(dm_list)
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/raven/raven/api/raven_channel.py", line 141, in get_extra_users
    return frappe.db.get_all(
           ^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 761, in get_all
    return frappe.get_all(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2007, in get_all
    return get_list(doctype, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1982, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
             ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'tabUser.type' in 'field list'")

Request Data

{
    "type": "POST",
    "args": {},
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/raven.api.raven_channel.get_all_channels",
    "request_id": null
}

Response Data

{
    "exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'tabUser.type' in 'field list'\")",
    "exc_type": "OperationalError",
    "_exc_source": "raven (app)"
}
nikkothari22 commented 2 months ago

I didn't update the version number, just pushed the change. Are you sure you're on the latest commit?

Is this running on Frappe Cloud or self hosted or local dev machine?

mohsinalimat commented 2 months ago

I didn't update the version number, just pushed the change. Are you sure you're on the latest commit?

Yes, it is latest commit.

Is this running on Frappe Cloud or self hosted or local dev machine?

self hosted for testing.

nikkothari22 commented 2 months ago

Can you check the "raven_channel.py" file - specifically the "get_extra_users" method?

It should be "Raven User" and not "User" here: https://github.com/The-Commit-Company/Raven/blob/e113f7cdf07419b030b4c88ebb4d730bd19a6836/raven/api/raven_channel.py#L142

mohsinalimat commented 2 months ago

This is the self hosted server code screenshot.

Screenshot 2024-05-02 at 2 37 36 PM

nikkothari22 commented 2 months ago

This is the self hosted server code screenshot.

Screenshot 2024-05-02 at 2 37 36 PM

Yep, code is the latest. It's not querying the "User" doctype, but the "Raven User" doctype. Not sure why you are still getting the error. If it's self-hosted, did you restart bench?

mohsinalimat commented 2 months ago

Yes. Already restarted.

dsatsangi commented 2 months ago

Facing the same issue. I even disabled the "Show Raven on Desk". But still the same error. I have hosted my app on frappecloud, I can't update the app.

App Versions

{
    "erpnext": "15.21.2",
    "frappe": "15.25.0",
    "hrms": "15.20.2",
    "india_compliance": "15.7.3",
    "lms": "1.0.0",
    "raven": "1.5.4"
}

Route

Form/Raven Channel/new-raven-channel-qarwgxpttj

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, 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 1761, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/raven/raven/api/raven_channel.py", line 44, in get_all_channels
    extra_users = get_extra_users(dm_list)
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/raven/raven/api/raven_channel.py", line 141, in get_extra_users
    return frappe.db.get_all(
           ^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 761, in get_all
    return frappe.get_all(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2050, in get_all
    return get_list(doctype, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 2025, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
             ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'tabUser.type' in 'field list'")

Request Data

{
    "type": "POST",
    "args": {},
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/raven.api.raven_channel.get_all_channels",
    "request_id": "c1541a76-9c27-4341-ab02-c28c8bfdfb7f"
}

Response Data

{
    "exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'tabUser.type' in 'field list'\")",
    "exc_type": "OperationalError",
    "_exc_source": "raven (app)"
}
nikkothari22 commented 2 months ago

@dsatsangi We have pushed a fix for this and then another update afterwards in v1.5.5.

If you are on a public bench, Frappe Cloud would have to update the app for you. @ankush Can we update the public bench?