ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Pull_from_email_account & email_account.receive errors


#1

Hi guys! I have a weird issue with reoccurring errors. Seems to have to do with my email-account?

My instance:

Vanilla ERPNext: v11.1.52 (version-11)
Frappe Framework: v11.1.48 (version-11)

My instance is running on a VPS with a custom domain and SSL.

I get two different error messages over and over:

#1 pull_from_email_account

{'site': 'erp.4ds.at', 'job_name': 'pull_from_email_account|4D Studio', 'is_async': True, 'method': <function pull_from_email_account at 0x7ff073d30268>, 'retry': 0, 'user': 'Administrator', 'kwargs': {'email_account': '4D Studio'}, 'log': <function log at 0x7ff073d9bc80>, 'event': 'all', 'method_name': 'pull_from_email_account'}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 103, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 713, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 301, in receive
    raise Exception(frappe.as_json(exceptions))
Exception: [
 "Traceback (most recent call last):\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 278, in receive\n    communication = self.insert_communication(msg, args=args)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 335, in insert_communication\n    email = Email(raw)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 372, in __init__\n    self.parse()\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 393, in parse\n    self.process_part(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 445, in process_part\n    self.text_content += self.get_payload(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 489, in get_payload\n    charset = self.get_charset(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 484, in get_charset\n    charset = chardet.detect(str(part))['encoding']\n  File \"/home/frappe/frappe-bench/env/lib/python3.5/site-packages/chardet/__init__.py\", line 34, in detect\n    '{0}'.format(type(byte_str)))\nTypeError: Expected object of type bytes or bytearray, got: <class 'str'>\n"
]

#2 email_account.receive

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 278, in receive
    communication = self.insert_communication(msg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 335, in insert_communication
    email = Email(raw)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 372, in __init__
    self.parse()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 393, in parse
    self.process_part(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 445, in process_part
    self.text_content += self.get_payload(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 489, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 484, in get_charset
    charset = chardet.detect(str(part))['encoding']
  File "/home/frappe/frappe-bench/env/lib/python3.5/site-packages/chardet/__init__.py", line 34, in detect
    '{0}'.format(type(byte_str)))
TypeError: Expected object of type bytes or bytearray, got: <class 'str'>

any help is greatly appreciated. thanks.


#2

The has been addressed in v11 and v12 by the Rockstars at GreyCube. (All hail Jignesh and Ashish!)

I think that it will get fixed in the regular Tuesday push.


#3

Thanks for the quick reply! Thats great to hear, seems it’s part of the -hotfix now, gonna give it a shot!


#4

Yes it is fixed we waiting for the push.


#5

Please reopen it is some more problem:

Installed Apps

ERPNext: v12.0.5 (version-12)

Frappe Framework: v12.0.5 (version-12)

pull_from_email_account

Error	

{'job_name': 'pull_from_email_account|Sales', 'method': <function pull_from_email_account at 0x7f76f7d2a8c8>, 'kwargs': {'email_account': 'Sales'}, 'log': <function log at 0x7f76f7d782f0>, 'event': 'all', 'method_name': 'pull_from_email_account', 'retry': 0, 'site': 'site1.local', 'user': 'Administrator', 'is_async': True}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 99, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 723, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 302, in receive
    raise Exception(frappe.as_json(exceptions))
Exception: [
 "Traceback (most recent call last):\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 279, in receive\n    communication = self.insert_communication(msg, args=args)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 336, in insert_communication\n    email = Email(raw)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 372, in __init__\n    self.parse()\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 393, in parse\n    self.process_part(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 445, in process_part\n    self.text_content += self.get_payload(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 492, in get_payload\n    charset = self.get_charset(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 487, in get_charset\n    charset = chardet.detect(part.encode())['encoding']\nAttributeError: 'Message' object has no attribute 'encode'\n"
]

email_account.receive

Error	

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 279, in receive
    communication = self.insert_communication(msg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 336, in insert_communication
    email = Email(raw)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 372, in __init__
    self.parse()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 393, in parse
    self.process_part(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 445, in process_part
    self.text_content += self.get_payload(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 492, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 487, in get_charset
    charset = chardet.detect(part.encode())['encoding']
AttributeError: 'Message' object has no attribute 'encode'

#6

I just seen that error in my instance as well - fresh install python3 easy install script ubuntu 18.04


#7

The issue is still exists: