Error Attaching Pdf File as private to Doctype via attach field

Hello everyone,

I’m encountering an issue with my custom application when attempting to attach a PDF file through an “attach” field.

I have a custom doctype called Record, which includes some attachment fields to allow users to attach files of various formats to each record.

The issue arises when attempting to attach a PDF file. While other file formats such as JPG, IFC, and PNG can be attached successfully, attempting to attach a PDF file results in the following error stack:

Examining this error stack, I’ve come to understand that the problem stems from a validation path issue. Specifically, while debugging the validate_file_path function, I’ve identified that the problem lies within this function.

When i print the values of the path when the error happens i get the following values:

BASE PATH = /home/andrea/Desktop/dbl/sites/dbl.dbl/private/files
os.path.realpath(self.get_full_path()) = /home/andrea/Desktop/dbl/sites/dbl.dbl/public/files/EPC_example5821d1.pdf

After observing this, I attempted to attach the PDF file as a public file, and the problem disappeared. Therefore, the issue seems to be related to attaching the file as private.

I’m quite puzzled by this situation and would appreciate any assistance, because i really need to attach all the files as private.

My setup is Frappe version 15, and i’m on Linux in a development enviroment.

Thank you.