Error after updating to 13.20.1

Dear all,

we are facing errors after updating our ERPnext installation from 13.19 to 13.20:

Traceback (most recent call last):
  File "apps/frappe/frappe/utils/background_jobs.py", line 110, in execute_job
    method(**kwargs)
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 840, in pull_from_email_account
    email_account.receive()
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 365, in receive
    raise Exception(frappe.as_json(exceptions))
Exception: [
 "Traceback (most recent call last):\n  File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 334, in receive\n    communication = self.insert_communication(msg, args=args)\n  File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 420, in insert_communication\n    frappe.db.set_value(\"Communication\", name, \"uid\", uid, update_modified=False)\n  File \"apps/frappe/frappe/database/database.py\", line 703, in set_value\n    query.run(debug=debug)\n  File \"apps/frappe/frappe/query_builder/utils.py\", line 59, in execute_query\n    return frappe.db.sql(query, params, *args, **kwargs) # nosemgrep\n  File \"apps/frappe/frappe/database/database.py\", line 146, in sql\n    self._cursor.execute(query, values)\n  File \"env/lib/python3.6/site-packages/pymysql/cursors.py\", line 148, in execute\n    result = self._query(query)\n  File \"env/lib/python3.6/site-packages/pymysql/cursors.py\", line 310, in _query\n    conn.query(q)\n  File \"env/lib/python3.6/site-packages/pymysql/connections.py\", line 548, in query\n    self._affected_rows = self._read_query_result(unbuffered=unbuffered)\n  File \"env/lib/python3.6/site-packages/pymysql/connections.py\", line 775, in _read_query_result\n    result.read()\n  File \"env/lib/python3.6/site-packages/pymysql/connections.py\", line 1156, in read\n    first_packet = self.connection._read_packet()\n  File \"env/lib/python3.6/site-packages/pymysql/connections.py\", line 725, in _read_packet\n    packet.raise_for_error()\n  File \"env/lib/python3.6/site-packages/pymysql/protocol.py\", line 221, in raise_for_error\n    err.raise_mysql_exception(self._data)\n  File \"env/lib/python3.6/site-packages/pymysql/err.py\", line 143, in raise_mysql_exception\n    raise errorclass(errno, errval)\npymysql.err.ProgrammingError: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b'2' WHERE `name` IN ('de5a39668d')' at line 1\")\n"

The error repeats every few minutes. Anything we can do to fix the issue?

What were the steps you followed for upgrade ?

We did a “pip3 install --user --upgrade frappe-bench” to update the bench first and then a “cd ~/frappe-bench; bench update” to update ERPnext. This is a procedure we have followed over the whole last year without any problems…

Try to run

bench build

Unfortunately that has not changed the behavior. We still do get two messages every three or so minutes, one labeled “pull_from_email_account” with details as shown above, and one labeled “Error” containing “email_account.receive” as error.

I’m not certain how this happens but the receive method fetches uids which are of the type bytes which causes this to break since frappe.db.set_value likes only str types.

I’ll raise a fix for this but for the time being, go to the file frappe/email/doctype/email_account/email_account.py and replace line 420 from

frappe.db.set_value("Communication", name, "uid", uid, update_modified=False)

to

frappe.db.set_value("Communication", name, "uid", frappe.safe_decode(uid), update_modified=False)

and restart your bench. This should do it.

Edit: Raised a PR to fix this

https://github.com/frappe/frappe/pull/16061

4 Likes

Thanks, Gavin, for your reply & fix. I have applied it and will report back the results.

1 Like

This has indeed healed the system. No more error messages in the log, yay!

1 Like

I have created sales order as an Accounting Dimension but while making a payment entry, the following error pops up when we click in the sales order feild on payment entry form. No solutions till now.

#paymententry #account #accounting #sales-order

You’d better repost your problem under an own topic to make sure it is being found by others…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.