Skip to content

Cloning a resource does not copy its custom metadata #14772

Open

Description

@etj

BaseResourceManager.copy() (geonode/resource/manager.py) re-links each join-table keyed by the source resource's pk individually and by hand: keywords, regions, tkeywords, contacts (ContactRole), and LinkedResource. SparseField — the table backing custom/sparse metadata fields — isn't in that list and is never copied, so any custom metadata on the source resource is silently dropped from the clone.

Proposed fix

Replace the manual keywords/tkeywords/regions/contacts re-linking with the metadata manager's own schema machinery:

  1. Read the source resource's full metadata via metadata_manager.build_schema_instance(instance, lang=None).
  2. Write it onto the clone via metadata_manager.update_schema_instance_partial(cloned_resource, schema_instance, user=owner) — the same call create() already uses for infer_default_metadata.

Since every metadata handler (including the sparse-field handler) participates in building and applying that schema instance, this covers SparseField and any other handler-backed field generically, instead of requiring each new field type to be special-cased in copy() by hand.

Behavior change to call out explicitly: LinkedResource

The current manual code copies LinkedResource links in both directions:

  • outgoing links where the source resource is the link's source, and
  • incoming links where the source resource is the link's target — in this case, it also adds a new link from the other resource to the clone (e.g. if Document D links to Map M, cloning M currently makes D link to the clone too).

LinkedResourceHandler (the metadata handler covering this field) only manages the outgoing direction. Switching to the schema-instance approach as described above would carry over outgoing links correctly but would stop propagating the incoming-direction relinking. This needs an explicit decision — keep that half as dedicated manual code alongside the schema-instance copy, or drop it as an intentional behavior change — rather than let it silently disappear as a side effect of the refactor.

Side notes

  • SparseField is also where migrated legacy ExtraMetadata values now live (see geonode/base/api/deprecated_extra_metadata.py), so today's bug incidentally drops those on clone too.
  • Metadata tracking is not yet implemented in copy()

Activity

  1. added this to the 5.2.0 milestone on Nov 17, 2026
  2. changed the title [-]Cloning resource does not copy custom metadata[/-] [+]Cloning a resource does not copy its custom metadata[/+] on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions