TypeError: clean() got an unexpected keyword argument 'protocols'

When update v11 with bench update

File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 616, in _sanitize_content
    sanitized_value = sanitize_html(value, linkify=df.fieldtype=='Text Editor')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/html_utils.py", line 67, in sanitize_html
    strip_comments=strip_comments, protocols=['cid', 'http', 'https', 'mailto'])
TypeError: clean() got an unexpected keyword argument 'protocols'

Same issue here.

missing python package?
i have try

pip install python-sanitize
pip install html-sanitize
pip install sanitize
pip install sanitize-html

but nothing changed

probably the error is in
/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py

elif df and (df.get("ignore_xss_filter")
            or (df.get("fieldtype")=="Code" and df.get("options")!="Email")
            or df.get("fieldtype") in ("Attach", "Attach Image")

            # cancelled and submit but not update after submit should be ignored
            or self.docstatus==2
            or (self.docstatus==1 and not df.get("allow_on_submit"))):
              continue
else:
                  sanitized_value = sanitize_html(value, linkify=df.fieldtype=='Text Editor')

i have comment out last 2 line

else:
                  sanitized_value = sanitize_html(value, linkify=df.fieldtype=='Text Editor')

and bench migrate work…where is the problem?

My understanding is that sanitize scans emails for suspect content like trojan links.

So my guess is possibly you have a ‘bad’ old email that fails to parse, if you could identify the problem email?

1 Like

it is possible! i have many imap account. thanks @clarkej. i will check

I tried commenting out the same last two lines but still get the same error. Any ideas on how to fix it?

I just tried rolling back to a 3 month old backup and the same error occurs? Any one else suffering from this error below?

Patching sites...
Migrating myurl.com.au
Executing frappe.patches.v10_0.set_default_locking_time in myurl.com.au (168b58451211c9e1)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 222, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v10_0/set_default_locking_time.py", line 7, in execute
    frappe.reload_doc("core", "doctype", "system_settings")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 774, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 155, in reload_doc
    return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 26, in import_files
    reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 31, in import_file
    ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 65, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 132, in import_doc
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 223, in insert
    self._validate()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 457, in _validate
    d._sanitize_content()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 616, in _sanitize_content
    sanitized_value = sanitize_html(value, linkify=df.fieldtype=='Text Editor')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/html_utils.py", line 67, in sanitize_html
    strip_comments=strip_comments, protocols=['cid', 'http', 'https', 'mailto'])
TypeError: clean() got an unexpected keyword argument 'protocols'

I have also deleted all email logs and reset all email accounts and domains but the issue persists. Any help would be great.

i have do same, but not solve

Thanks for the reply. Have also deleted patch but then ERPNext hangs. Reset all Git files and settings. Odd. Am running CentOS7 on a Digital Ocean Droplet. How about you?