Cannot view private files after updating to version 13 from version 12 (frappe.exceptions.DuplicateEntryError)

I’m having trouble access trouble access private files after updating to erpnext. If I uncheck ‘is_private’ checkbox then the file shows up fine.

The traceback is as follow:

Traceback (most recent call last):
File “apps/frappe/frappe/model/”, line 363, in db_insert
frappe.db.sql(“”"INSERT INTO tab{doctype} ({columns})
File “apps/frappe/frappe/database/”, line 148, in sql
self._cursor.execute(query, values)
File “env/lib/python3.8/site-packages/pymysql/”, line 148, in execute
result = self._query(query)
File “env/lib/python3.8/site-packages/pymysql/”, line 310, in _query
File “env/lib/python3.8/site-packages/pymysql/”, line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “env/lib/python3.8/site-packages/pymysql/”, line 775, in _read_query_result
File “env/lib/python3.8/site-packages/pymysql/”, line 1156, in read
first_packet = self.connection._read_packet()
File “env/lib/python3.8/site-packages/pymysql/”, line 725, in _read_packet
File “env/lib/python3.8/site-packages/pymysql/”, line 221, in raise_for_error
File “env/lib/python3.8/site-packages/pymysql/”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘AL-01229’ for key ‘PRIMARY’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “apps/frappe/frappe/”, line 74, in application
response = frappe.utils.response.download_private_file(request.path)
File “apps/frappe/frappe/utils/”, line 182, in download_private_file
make_access_log(doctype=‘File’,, file_type=os.path.splitext(path)[-1][1:])
File “apps/frappe/frappe/core/doctype/access_log/”, line 28, in make_access_log
File “apps/frappe/frappe/”, line 647, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
File “apps/frappe/frappe/core/doctype/access_log/”, line 59, in _make_access_log
File “apps/frappe/frappe/model/”, line 253, in insert
raise e
File “apps/frappe/frappe/model/”, line 250, in insert
File “apps/frappe/frappe/model/”, line 381, in db_insert
raise frappe.DuplicateEntryError(self.doctype,, e)
frappe.exceptions.DuplicateEntryError: (‘Access Log’, ‘AL-01229’, IntegrityError(1062, “Duplicate entry ‘AL-01229’ for key ‘PRIMARY’”))

I solve this problem this way for anyone who is having the same trouble.

The issue is similar laid out by this post: Print Preview Error {{body}} - #11 by brian_pond.

This involves the current value in tabSeries and the current value of the blank entry in the same table.

This is the code I used to solve my problem. I logged into my database as root and ran these command.

SELECT name, current FROM tabSeries WHERE name like ‘AL%’
| name | current |
| AL- | 2127 |

select name, current from tabSeries;

| name | current |
| | 1228 |
| ACC-ASS-2020- | 6 |

SELECT name, current FROM {erpnext_database_name}.tabSeries WHERE name= ’ ';

update {erpnext_database_name}.tabSeries set current = 2128 where name= ’ ';

After updating the blank field value to higher than that of the AL series, everything now works fine.