Error in attaching files

Hi,
I am facing below error while attaching files, it was working fine in the past but i don’t know how this error comes,
Please Help ASAP,

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/desk/form/utils.py", line 17, in remove_attach
    return frappe.utils.file_manager.remove_file(fid)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 245, in remove_file
    frappe.delete_doc("File", fid, ignore_permissions=ignore_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 673, in delete_doc
    ignore_permissions, flags, ignore_on_trash, ignore_missing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 92, in delete_doc
    doc.run_method("after_delete")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 758, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1027, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1010, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 752, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 227, in after_delete
    self.update_parent_folder_size()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 131, in update_parent_folder_size
    frappe.get_doc("File", self.folder).set_folder_size()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/file/file.py", line 114, in set_folder_size
    self.db_set('file_size', self.file_size)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 960, in db_set
    self.modified, self.modified_by, update_modified=update_modified)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 678, in set_value
    values, debug=debug)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 166, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 893, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1103, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1396, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1059, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 384, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
DataError: (1264, u"Out of range value for column 'file_size' at row 1")

Hi @shahid

I have checked on my local account and it’s working, I am able to attache 5 MB file in the File Manager. Can you share the steps to replicate the issue? Also can you share the size of the file.
If you’re attaching the file to the document, please save the document first and then attach the file.

Its giving me the error in every attachment in any form.
its not because the size of a specific file i am attaching, it is even giving me the error when i am going to attach a only few KBs file.

This error is genuine. I can confirm this on v10. The problem is in tabFile it keeps a record of the folder size for folders like Home and Attachment. Once these folder sizes go beyond a certain size (i.e. INT 11, which is specified in the table column datatype) this errors out.

A permanent fix would be to change the table datatype to a larger INT or BIGINT.

I guess the easy way is to change the field type in Doctype to something that represents a BIGINT or LONG INT. Anyone knows if there is such a type in DOCTYPE or perhaps what the equivalent?

I’ve already done this, But still same error.

ALTER TABLE tabFile MODIFY file_size BIGINT;

Currently i am managing this problem by deleting old files :frowning:

This has been fixed handle Int overflow by manassolanki · Pull Request #5607 · frappe/frappe · GitHub

I am on v10
ERPNext: v10.1.33 (master)
Frappe Framework: v10.1.31 (master)

How can i update to v11 in easy way, without loosing anything.
Please note that that i’ve made many changes in core files.

I just checked again, it has been fixed in v10. So if you are on latest v10 it should be solved

Hii
I am getting same error, have you found any solution yet?