uwazi
uwazi copied to clipboard
"Ghost" metadata creating validation error on multi-edit
Describe the bug When a template has been deleted and some relationships (or inherited relationships) exists on other templates pointing to the template that was deleted, multi-editing entities that had PREVIOUSLY FILLED data will fail validation.
Single-editing them works as expected as the process is sanitizing the data, but multi-editing flow means that "invalid" metadata properties are being sent to the backend.
To Reproduce Steps to reproduce the behavior (theoretical, not fully tested, may require extra steps or looking into the scenario with more detail):
- Have templates A and B
- Assign to template A a relationship property to template B (may require inherited relationship, not sure)
- Create entities on template A pointing to some entities on template B
- Delete template B (this may require to remove the properties from template A?)
- Try to bulk-edit entities in template A
Screenshots
I am no sure if this is backend or frontend issue. The backend should still not accept the extra properties, but the front-end should sanitize them before sending them. cc @daneryl ?
There are still concerns about what approach to take and where to "fix" the data: upon template deletion, upon backend data "send", on client as a "lazy" migration (this would require EVERY client to do that consistently), etc.
After discussion: we have determined that the real issue is that the template deletion flow only removes the property, but not the metadata from the entities (as contrast: the normal property deletion flow on the templates does correctly update the entities). The multi-edit flow is not the culprit, it is just passing along the faulty data that is coming from the database, and the entity save validation fails correctly. We have agreed to:
- correct the template deletion flow
- write a migration to find and correct existing examples
This way we will have a consistent database state immediately.