"frappe.exceptions.ValidationError: You can only upload JPG, PNG, PDF, TXT or Microsoft documents

I am facing this issue when user is trying to attach file with extension of xmprj. I checked handler.py code

if content is not None and (
		frappe.session.user == "Guest" or (user and not user.has_desk_access())
		filetype = guess_type(filename)[0]
		if filetype not in ALLOWED_MIMETYPES:
			frappe.throw(_("You can only upload JPG, PNG, PDF, TXT or Microsoft documents."))

Looking at check should only be there for users who doesn’t have desk access , I cross checked the role of user it has desk access. I have created custom role which has desk access but still this user is not able to attach the file of other extensions. I have another custom role which is able to attach file of any extension, this role also has desk access. I am clueless on this why will this validation exception will be thrown if the role has desk access.

Hi @vishwajeets,

If the guest user then allowed only the below type.

please check the code reference:

Some formats don’t support it. if you have any idea then you can contribute it.

Thank You!

Thank you for your inputs I do understand that guest user is allowed to attach specific extension but here what I am referring to is not a guest user but a system user who has role which has desk access.It works for one custom role but doesn’t work for other so makes me wonder what’s the real logic implemented is.

Hi @vishwajeets,

You should explore the handler file and how it will works for guests and other roles.

We just share the functionally and reference code.

I hope this helps.

Thank You!

I have already explore the file as mentioned in my thread , I was looking at some concrete response on the behavior. Thank you