DVinyl icon indicating copy to clipboard operation
DVinyl copied to clipboard

[Feature]: Detect and safely resolve overlaps between custom and native plugin fields

Open ArtwoXYZ opened this issue 2 months ago • 3 comments

Before suggesting

  • [x] I searched the existing issues and did not find a similar request.

What problem would this solve?

I have customized some of the built-in plugins by adding my own fields.

I eventually ran into a problem after DVinyl added a native field whose generated name matched one of my existing custom fields. The custom and native fields then had the same technical identifier.

Their values are stored at different MongoDB paths (item.extra[name] for custom fields and the native schema path for built-in fields), so the data is not necessarily overwritten. However, both fields are exposed to the form and view layer using the same name. This makes them ambiguous, can hide the custom value, and makes form submissions unsafe or unpredictable.

The only warning appeared when I later opened and saved the plugin customization. DVinyl did not detect or report the conflict immediately after the update. The error was also generic, such as “A custom field uses a reserved name” or “Two custom fields share the same name”, without identifying the affected plugin or fields.

This is likely to happen more often as built-in plugins evolve. Requests such as #140, #147 and #149 may add or extend native fields that users have already recreated locally.

An update should never make a custom field silently conflict with a newly introduced native field, and resolving such a conflict should not require database access or manual data migration.

How could it work?

I suggest separating technical field identity from the user-facing label, then adding a small conflict-resolution workflow.

1. Give custom fields collision-proof identifiers

New custom fields should receive a stable identifier from a namespace reserved exclusively for user-created fields, for example:

  • custom_playtime
  • or, more safely, custom_<short-id>

The label (“Playtime”) would remain separate from this internal identifier.

Native plugins should never be allowed to declare field names starting with the reserved custom_ prefix. Renaming a custom field's label should not change its identifier or move its existing data.

Existing custom fields could be migrated to the new namespace during startup or backup restoration. The migration would need to update:

  • the field definition in settings.pluginExtraFields;
  • its values in item.extra;
  • card field selections;
  • the corner field selection;
  • any other setting that stores a field name.

For example, a legacy custom field stored as extra.playtime could become extra.custom_playtime, while a new native playtime field remains independent.

2. Detect possible duplicates automatically after an update

Once plugins have been loaded, DVinyl should compare every collection's custom field definitions with the current native plugin fields.

This check should not wait for the user to edit and save the plugin.

There could be two levels:

  • Technical conflict: a legacy custom field has exactly the same effective identifier as a native field.
  • Possible functional duplicate: the identifiers are safe, but the normalized labels or slugs match, for example custom “Playtime” and built-in “Playtime”.

Only collection admins need to see the warning. A banner or badge in the admin/plugin editor could say:

Games has one field to review after the update: custom field “Playtime” may duplicate the new built-in field “Playtime”. [Review] [Later]

Possible duplicates should be warnings rather than hard errors because users may intentionally keep two similar fields.

3. Provide a simple conflict resolver

The review screen could show both fields side by side:

Games

Custom: Playtime | custom_playtime | Number | used by 84 items
Built-in: Playtime | playtime | Number
Status: Compatible values

The available actions could be:

  1. Use the built-in field Transfer compatible custom values to the native field, then remove the custom field definition.

  2. Keep both Mark the overlap as intentional so it is not reported again. If both labels are identical, offer to rename the custom label so users can distinguish them.

  3. Rename the custom field Change only its label. Its stable internal identifier and existing values remain unchanged.

  4. Remove the custom field Clearly state how many items contain data first. If possible, distinguish “remove from the interface but retain the raw values for recovery” from “permanently delete the stored values”.

The admin should also be able to postpone the decision. The application should remain usable and the warning should stay available without blocking ordinary users.

4. Keep every resolution clear and safe

Every warning or validation error should identify the plugin and both fields, including their label, type, identifier and origin. For example:

Custom field “Playtime” (custom_playtime) may duplicate the built-in Games field “Playtime” (playtime).

When transferring data, DVinyl should first show how many values can be moved and whether any items already contain a different native value. It should never overwrite those values silently, and the custom source data should remain untouched until the transfer completes successfully.

If the field types or select options are incompatible, the transfer action should be disabled or require an explicit value mapping. Removing a populated field should likewise show the number of affected items and require confirmation.

Suggested acceptance criteria

  • A new custom field can never share a technical identifier or form name with a native field.
  • Existing custom field definitions and values are migrated without data loss.
  • Card and corner field references continue to work after migration.
  • A native plugin update triggers a visible admin warning without requiring the plugin customization to be opened or saved.
  • The warning clearly identifies both fields.
  • The admin can transfer, keep, rename or remove the custom field.
  • Conflicting native values are never overwritten silently.
  • An intentionally kept pair can be marked as resolved.
  • Backup restoration runs the same migration and conflict detection.
  • Regular users are not blocked by unresolved warnings.

Alternatives you considered

The best simpler alternative would probably be to only introduce the reserved custom_ namespace in a future version, migrate existing custom field identifiers to it, and leave any semantic duplicate or data transfer for the user to handle manually.

This would at least prevent future native fields from technically colliding with custom fields, so plugin updates would no longer break or hide them. However, users would not be warned when a new native field duplicates something they already created, and consolidating both fields would still require manual work.

Only adding more names to the reserved-field list would postpone the problem because future native field names cannot all be predicted.

Automatically deleting or merging a custom field when a native field appears would be too risky: the types may differ, the native field may already contain another value, or the user may intentionally want to keep both.

Would you like to help build it?

I could open a PR for it

ArtwoXYZ avatar Sep 07 '26 10:09 ArtwoXYZ

hi! yeah great idea :D That can be tricky! I'll let you handle it if you feel up to it ;)

Kyonew avatar Sep 07 '26 17:09 Kyonew

Thanks! I’ve started working on this! I’m planning to split it into two PRs:

  1. Custom field IDs and migration: give custom fields stable, collision-proof IDs and migrate existing fields, values, card settings and backups safely.
  2. Conflict review and resolution: warn admins about possible duplicates and let them keep both fields, rename or remove the custom field, or safely move its values to the built-in field.

I’m starting with the first PR so future plugin updates can no longer create technical field collisions.

ArtwoXYZ avatar Sep 07 '26 23:09 ArtwoXYZ

Hi! 4.0.0 is out with part 2: move a custom field's values into the built-in one, or keep both. Thanks for part 1 and the design!

Kyonew avatar Nov 15 '26 17:11 Kyonew