[Fixes #14651][5.1.x] Management command for metadata validation - #14679
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Empty choices remain invalid, schema failures can be omitted or return success, and the new command lacks coverage and bounded reporting memory.
Review effort: Balanced
Findings: 4
Open (5)
What changed in this PR
Adds metadata validation and reporting for resources, addressing issue #14651.
Changes:
- Adds JSON/CSV metadata validation command with filtering.
- Improves nullable schema choices and thesaurus labels.
- Enforces mandatory thesauri and adds related tests.
| File | Description |
|---|---|
geonode/metadata/management/__init__.py |
Initializes management package. |
geonode/metadata/management/commands/__init__.py |
Initializes command package. |
geonode/metadata/management/commands/validate_metadata.py |
Implements validation and reporting command. |
geonode/metadata/handlers/abstract.py |
Adds nullable-choice helpers. |
geonode/metadata/handlers/base.py |
Adds null options to enumerated fields. |
geonode/metadata/handlers/sparse.py |
Fixes labels and sparse-field nullability. |
geonode/metadata/handlers/thesaurus.py |
Enforces mandatory thesauri. |
geonode/metadata/schemas/base.json |
Marks optional fields nullable. |
geonode/metadata/tests/test_handlers.py |
Tests thesaurus requiredness. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 5.1.x #14679 +/- ##
========================================
Coverage ? 75.37%
========================================
Files ? 987
Lines ? 62224
Branches ? 8549
========================================
Hits ? 46901
Misses ? 13409
Partials ? 1914 🚀 New features to boost your workflow:
|


Add a
validate_metadatamanagement command, and report the schema bugs it foundWalks the resources, builds each one's jsonschema instance via
metadata_manager, and validates it against the metadata schema. Filters by id and resource type, reports to JSON or CSV, exits non-zero when anything is invalid.Writing it surfaced three genuine bugs in the schema generation, fixed here:
sparse.pyemitted"title": nullfor thesaurus keywords with no label in the requested language, so the fallback to the default label was missing.nullflagged every resource that left them empty. Nullable fields now get an explicit-choice in theironeOf(_add_oneof_null_option, shared by the base subhandlers and the sparse thesauri).card_min > 0was never enforced:minItemsalone only constrains a list already present. The mandatory thesauri now go intkeywords.required, andgeonode:requiredpromotestkeywordsitself.The report separates the two failure kinds: an empty mandatory field is reported against the resource, while an optional field the schema won't let be null is a schema defect, warned about once with the number of resources affected. Errors carry both the JSON path and the resolved field titles, so a
/tkeywords/3-2-4-1-gemet-inspire-themesrow is readable.Fixing the
null/oneOfschema problem (nullable properties restricted tooneOflist needed an entry withl keynull) uncovered a problem client side, addressed by GeoNode/geonode-mapstore-client#2668Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.