Upload attachment file with special characters

Hi all,

we have a seemingly new issue: when trying to attach a file to any record where the file name contains special characters (e.g. tüv.png), the upload fails with

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 400, in validate_filename
    hash_ = get_content_hash(filename)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 313, in get_content_hash
    content = content.encode()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 8: ordinal not in range(128)

Removing the special character is a workaround. However, this should work. Can someone confirm this?

Observed in ERPNext: v10.1.18 (master), Frappe Framework: v10.1.16 (master)

Note: this has worked in the past (the same system contains uploaded files with special characters)…

The issue you are referring to was fixed a month ago.

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

You can pull the latest updates to get the fix for it. Duplicate filenames are now handled by attaching the timestamp of when they are being uploaded to avoid confusion.

1 Like

Thank you, it is corrected in ERPNext: v10.1.31 (master), Frappe Framework: v10.1.30 (master)