Remove ExtraMetadata in favor of SparseFields#14001
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
…ata model Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
|
@copilot format with back, checks are failing because of it |
Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
Fixed in cfc914c. The flake8 errors were:
|
|
@copilot code is faling with "django.core.exceptions.ImproperlyConfigured: Field name |
Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/d5187544-0996-458a-88b7-66628254cbf4 Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
Fixed in c1a9e81. |
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
|
@copilot create another pull request which implements the back compatibility adapters described in the original issue. The API adapters are temporary (so they should be marked as deprecated), and they shall be pretty well isolated so that it will be easy to remove them after the deprecation period. |
|
@copilot black check is failing |
…ts.py Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/8a0d75b5-2c96-4456-9d56-6bef8adfdd7f Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
There was a problem hiding this comment.
Pull request overview
Removes the legacy ExtraMetadata model/M2M field and related API surface, migrating stored data into metadata.SparseField and cleaning up associated update paths and tests. The PR also introduces a deprecated compatibility layer that re-exposes the legacy /extra_metadata/ endpoint and metadata serializer field using SparseField.
Changes:
- Add a data+schema migration to move
ExtraMetadatarows intoSparseFieldand drop theExtraMetadatamodel /ResourceBase.metadatafield. - Remove legacy
ExtraMetadatausage across resource update codepaths, serializers/views, and Tastypie filtering. - Replace removed behavior with a deprecated adapter (
DeprecatedExtraMetadataMixin/DeprecatedExtraMetadataField) plus new compatibility tests.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| geonode/settings.py | Reworks (and partially retains) legacy ExtraMetadata-related settings for backward compatibility. |
| geonode/resource/utils.py | Removes ExtraMetadata import and extra_metadata handling from update_resource(). |
| geonode/resource/manager.py | Removes extra_metadata parameter plumbing into update_resource(). |
| geonode/maps/api/tests.py | Removes tests asserting legacy include[]=metadata behavior. |
| geonode/layers/api/tests.py | Removes tests asserting legacy include[]=metadata behavior. |
| geonode/layers/api/serializers.py | Drops metadata from dataset serializer fields. |
| geonode/geoapps/api/tests.py | Removes tests asserting legacy include[]=metadata behavior. |
| geonode/documents/api/tests.py | Removes tests asserting legacy include[]=metadata behavior. |
| geonode/base/utils.py | Removes validate_extra_metadata() and related imports. |
| geonode/base/models.py | Removes ResourceBase.metadata M2M and deletes ExtraMetadata model. |
| geonode/base/migrations/0098_migrate_extrametadata_to_sparsefields.py | Adds migration to move ExtraMetadata data into SparseFields and then drop the old schema. |
| geonode/base/api/views.py | Removes legacy extra_metadata action and mixes in the deprecated compatibility adapter. |
| geonode/base/api/tests.py | Removes old ExtraMetadata API tests and adds tests for the deprecated compatibility adapter. |
| geonode/base/api/serializers.py | Replaces old ExtraMetadataSerializer field with a deprecated computed field backed by SparseField. |
| geonode/base/api/deprecated_extra_metadata.py | Implements deprecated compatibility: legacy /extra_metadata/ action + metadata field backed by SparseField. |
| geonode/api/tests.py | Removes Tastypie tests for metadata filtering. |
| geonode/api/resourcebase_api.py | Removes Tastypie metadata__* filter plumbing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -2196,6 +2188,7 @@ def get_geonode_catalogue_service(): | |||
| }, | |||
| **CUSTOM_METADATA_SCHEMA, | |||
| } | |||
|
|
||
| """ | ||
| Kept for backward compatibility with geonode_mapstore_client and other packages | ||
| that may still reference this setting. ExtraMetadata has been removed in favour | ||
| of SparseFields; this empty dict prevents AttributeError on startup. | ||
| """ | ||
| EXTRA_METADATA_SCHEMA = {} | ||
|
|
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("base", "0097_alter_link_asset"), |
| warnings.warn(DEPRECATION_REASON, DeprecationWarning, stacklevel=2) | ||
| logger.warning(DEPRECATION_REASON) |
| "[DEPRECATED] Get/Update/Delete/Add extra metadata for a resource. " "Use the sparse fields API instead." | ||
| ), | ||
| deprecated=True, | ||
| ) | ||
| @action( | ||
| detail=True, | ||
| methods=["get", "put", "delete", "post"], |
|
@copilot on master drf-spectacular has been removed. Pls remove related dependencies on the code as well, since tests are failing. |
Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/5fc50f73-190e-46f5-b7fd-2d885ed21c7c Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
Fixed in 2f245ad. Removed the |
|
@copilot fix
|
…cebase_auth_config Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/cb857a4d-d999-4228-ad98-fe4648e898aa Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
Fixed in fecb49e. Renamed |
|
@copilot error in black formatting |
Agent-Logs-Url: https://github.com/GeoNode/geonode/sessions/a710ea51-7e89-45d3-a6d4-74229bd12a5c Co-authored-by: etj <717359+etj@users.noreply.github.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @Copilot on file. In order for us to review and merge your code, please contact the project maintainers to get yourself added. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14001 +/- ##
===========================================
+ Coverage 43.23% 74.63% +31.40%
===========================================
Files 960 969 +9
Lines 58824 59229 +405
Branches 8018 8066 +48
===========================================
+ Hits 25432 44208 +18776
+ Misses 32113 13204 -18909
- Partials 1279 1817 +538 🚀 New features to boost your workflow:
|
| @@ -2196,6 +2188,7 @@ def get_geonode_catalogue_service(): | |||
| }, | |||
| **CUSTOM_METADATA_SCHEMA, | |||
| } | |||
| @@ -2196,6 +2188,7 @@ def get_geonode_catalogue_service(): | |||
| }, | |||
| **CUSTOM_METADATA_SCHEMA, | |||
| } | |||
| # ---- End deprecated ExtraMetadata settings ---- | |||
|
|
|||
| """ | |||
| List of modules that implement custom metadata storers that will be called when the metadata of a resource is saved | |||
| @@ -2204,6 +2197,13 @@ def get_geonode_catalogue_service(): | |||
| # 'geonode.resource.regions_storer.spatial_predicate_region_assignor', | |||
| ] | |||
|
|
|||
| """ | |||
| Kept for backward compatibility with geonode_mapstore_client and other packages | |||
| that may still reference this setting. ExtraMetadata has been removed in favour | |||
| of SparseFields; this empty dict prevents AttributeError on startup. | |||
| """ | |||
| EXTRA_METADATA_SCHEMA = {} | |||
|
|
|||
| links = DynamicRelationField(LinksSerializer, source="id", read_only=True) | ||
|
|
||
| # Deferred fields | ||
| metadata = ComplexDynamicRelationField(ExtraMetadataSerializer, many=True, deferred=True) | ||
| # Deprecated: use the sparse fields API instead of ``metadata``. | ||
| metadata = DeprecatedExtraMetadataField(deferred=True, read_only=True) | ||
| data = DataBlobField(DataBlobSerializer, source="id", deferred=True, required=False) |
| @action( | ||
| detail=True, | ||
| methods=["get", "put", "delete", "post"], | ||
| url_path=r"extra_metadata", | ||
| url_name="extra-metadata", | ||
| ) | ||
| def extra_metadata(self, request, pk, *args, **kwargs): | ||
| """Deprecated endpoint – delegates to SparseField storage.""" | ||
| warnings.warn(DEPRECATION_REASON, DeprecationWarning, stacklevel=2) | ||
| logger.warning(DEPRECATION_REASON) | ||
|
|
||
| resource = ResourceBase.objects.filter(pk=pk).first() | ||
| if resource is None: | ||
| return Response({"detail": "Not found."}, status=404) | ||
|
|
||
| if request.method == "GET": | ||
| return self._extra_metadata_get(request, resource) | ||
| elif request.method == "POST": | ||
| return self._extra_metadata_post(request, resource) | ||
| elif request.method == "PUT": | ||
| return self._extra_metadata_put(request, resource) | ||
| elif request.method == "DELETE": | ||
| return self._extra_metadata_delete(request, resource) | ||
|
|
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("base", "0099_resourcebase_auth_config"), | ||
| ("metadata", "0001_initial"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(migrate_extrametadata_to_sparsefields, migrations.RunPython.noop), | ||
| migrations.RemoveField( |
ExtraMetadatawas a stopgap for storing custom per-resource metadata. With the metadata JSON schema system andSparseFieldnow available,ExtraMetadatais superseded and can be removed.Migration
A single migration (
0098) handles both data and schema changes:ExtraMetadatarow is migrated to aSparseFieldentry withname=extra_metadata_<pk>andvalue=json.dumps(metadata_dict). Entries whose serialized JSON exceeds the 1024-charSparseField.valuelimit are skipped with a warning.metadataM2M field fromResourceBaseand drops theExtraMetadatamodel.Code removal
base/models.py: RemovedExtraMetadatamodel andResourceBase.metadataM2M field.base/api/serializers.py: RemovedExtraMetadataSerializerandmetadatadeferred field fromResourceBaseSerializer.base/api/views.py: Removedextra_metadataREST action (GET/PUT/POST/DELETE on/{pk}/extra_metadata/).base/utils.py: Removedvalidate_extra_metadata()and itsschema/settingsimports.resource/utils.py/resource/manager.py: Removedextra_metadataparameter fromupdate_resource()andResourceManager.update().api/resourcebase_api.py: Removedmetadata__*query param filtering from the legacy Tastypie API.settings.py: RemovedDEFAULT_EXTRA_METADATA_SCHEMA,CUSTOM_METADATA_SCHEMA,EXTRA_METADATA_SCHEMA, andfrom schema import Optional.Tests
Removed
TestExtraMetadataBaseApiand alltest_extra_metadata_included_with_param/test_metadata_filterstests that covered the now-deleted functionality.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.