frappe.exceptions.ValidationError: item_code field cannot be set as unique in tabItem, as there are non-unique existing values

In post # 2 above Sangram’s advice seems worth a try.

anand gives similar advice and also a PR fix to refine a validation to prevent that case.

To identify exactly what non-unique Item records are causing the problem might help clarify your problem case. To inspect the database would require sql skills.