Multiple complex migration failures require careful handling of corrupted data and validation logic.
The issue involves multiple migration failures related to workspace JSON parsing, Custom DocPerm validation, and User Type role validation. The migration process aborts due to these errors, leaving the system in an inconsistent state. Fixing this requires handling corrupted data and improving validation logic.
Issue Statement Running bench --site migrate fails with multiple inconsistent errors related to: • Empty workspace JSON file • Missing Custom DocPerm • Invalid User Type role validation • Missing User Type: Employee Self Service Migration aborts and leaves the system in a partially migrated and inconsistent state.
Detailed Description During migration, several critical failures occur in sequence:
Workspace JSON Parsing Failure If a workspace file exists but is empty (0 bytes), migration crashes with: bad json: .../erpnext/workspace/home/home.json orjson.JSONDecodeError: input data is empty: line 1 column 1 (char 0) Stack excerpt: entity_json = read_doc_from_file(file) doc = orjson.loads(f.read()) Instead of gracefully skipping or clearly reporting the invalid file, the entire migration aborts.
Custom DocPerm None Not Found After partial fixes, migration fails with: frappe.exceptions.DoesNotExistError: Custom DocPerm None not found This appears to be triggered by corrupted or partially created Custom DocPerm records where name is NULL or invalid. The framework does not clearly indicate: • Which DocType caused the issue • Why None is being referenced • How to safely repair the broken state
Role Validation Error (HRMS) Migration then fails with: frappe.exceptions.ValidationError: The role Employee Self Service should be a custom role. The validation enforces that the role attached to User Type: Employee Self Service must be custom. However: • In some setups, Employee Self Service may already exist. • The error does not clearly explain how to repair legacy data. • The system blocks migration instead of auto-correcting or providing guidance.
User Type Missing Error In other attempts, migration fails with: frappe.exceptions.DoesNotExistError: User Type Employee Self Service not found This occurs when: • The User Type record is missing • Or was partially deleted during manual repair attempts Again, migration ha
Claim this issue to let others know you're working on it. You'll earn 35 points when you complete it!