Skip to content

[Fixes #14686][5.1.x] Metadata: handler registration order - #14687

Merged
giohappy merged 3 commits into
5.1.xfrom
14686_51x_metadata_order
Oct 5, 2026
Merged

giohappy merged 3 commits into
5.1.xfrom
14686_51x_metadata_order

Conversation

@etj

@etj etj commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

#14686

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

For all pull requests:

  • Confirm you have read the contribution guidelines
  • You have sent a Contribution Licence Agreement (CLA) as necessary (not required for small changes, e.g., fixing typos in the documentation)
  • Make sure the first PR targets the master branch, eventual backports will be managed later. This can be ignored if the PR is fixing an issue that only happens in a specific branch, but not in newer ones.

The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):

  • There is a ticket in https://github.com/GeoNode/geonode/issues describing the issue/improvement/feature (a notable exemption is, changes not visible to end-users)
  • The issue connected to the PR must have Labels and Milestone assigned
  • PR for bug fixes and small new features are presented as a single commit
  • PR title must be in the form "[Fixes #<issue_number>] Title of the PR"
  • New unit tests have been added covering the changes, unless there is an explanation on why the tests are not necessary/implemented

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.

@etj etj self-assigned this Oct 2, 2026
Copilot AI balanced review requested due to automatic review settings October 2, 2026 11:49
@cla-bot cla-bot Bot added the cla-signed CLA Bot: community license agreement signed label Oct 2, 2026
@etj
etj requested a review from mattiagiupponi October 2, 2026 11:50
@etj etj added this to the 5.1.1 milestone Oct 2, 2026
@etj etj linked an issue Oct 2, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Runtime registration remains lifecycle-unsafe, and moving multilang contradicts the linked issue’s stated scope.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds deterministic ordering for metadata handlers across core and external modules.

Changes:

  • Introduces initial, default, and final handler priorities.
  • Sorts handlers during registration.
  • Adds ordering tests and extension documentation.
File Description
geonode/​metadata/​manager.py Adds ordered registration.
geonode/​metadata/​apps.py Registers configured handler groups.
geonode/​metadata/​settings.py Defines handler buckets.
geonode/​metadata/​tests/​test_handler_order.py Tests ordering behavior.
geonode/​metadata/​tests/​tests.py Updates registry assertions.
docs/​src/​development/​metadata/​design.md Documents registration and ordering.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread geonode/metadata/manager.py Resolved
Comment thread geonode/metadata/settings.py Resolved
Comment thread docs/src/development/metadata/design.md Resolved
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.04545% with 49 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (5.1.x@fb92702). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             5.1.x   #14687   +/-   ##
========================================
  Coverage         ?   75.54%           
========================================
  Files            ?      993           
  Lines            ?    62741           
  Branches         ?     8634           
========================================
  Hits             ?    47398           
  Misses           ?    13425           
  Partials         ?     1918           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@etj
etj requested a balanced review from Copilot October 2, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread geonode/metadata/settings.py Resolved
Comment thread geonode/metadata/tracking/operation.py Resolved
Comment thread geonode/resource/manager.py Resolved
Comment thread geonode/resource/manager.py Resolved
@etj
etj requested review from nrjadkry and a balanced review from Copilot and removed request for mattiagiupponi October 5, 2026 10:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resource updates snapshot metadata after mutations, omitting primary changes from tracked deltas, and fallback-user failures can surface after successful saves.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (7)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Handle missing fallback user without failing successful updates

geonode/​metadata/​tracking/​operation.py:92

Resolving the fallback user happens outside the per-resource exception handling. If METADATA_TRACK_DEFAULTUSER does not exist, default_user() raises out of metadata_tracker(None) after the resource update has succeeded; this turns successful manager updates into errors even though tracking failures elsewhere are deliberately logged without breaking the save. Catch this lookup failure as well and log it.

Low severity Document support for omitted users in metadata tracking

docs/​src/​development/​metadata/​tracking.md:26

This says the user cannot be omitted, but the public context manager explicitly supports metadata_tracker(None), BaseResourceManager.update() uses that path, and a nested save may attribute the operation later or it falls back to the configured default. Document that behavior so integrations do not invent a user merely to satisfy this statement.

Comment thread geonode/resource/manager.py Outdated
Comment on lines +425 to +427
# One update is one metadata change, however many saves it takes. `user` is whoever
# asked for it, when the caller knows: the request-driven ones do
with metadata_tracker(user):
@etj
etj force-pushed the 14686_51x_metadata_order branch from 7ec2e90 to 69fb9e7 Compare October 5, 2026 11:45
@etj
etj requested a balanced review from Copilot October 5, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Tracking boundaries, fallback-user handling, terminal ordering, and user propagation can currently produce incomplete attribution or break updates.

Review effort: Balanced
Findings: 2 High severity · 3 Medium severity

Open (5)

Comment on lines +85 to +93
# an operation nobody claimed is still recorded, under the default user, marked as not theirs
user, attributed = (self.user, True) if self.user is not None else (default_user(), False)

for resource, before in self.snapshots.values():
try:
track_change(resource, before, user, attributed)
except Exception as e:
logger.error(f"Can not track the changes of resource {resource.pk}", exc_info=e)

Comment thread geonode/metadata/settings.py Resolved
keywords: list = [],
custom: dict = {},
notify: bool = True,
user: settings.AUTH_USER_MODEL = None,
Comment on lines +425 to +427
# One update is one metadata change, however many saves it takes. `user` is whoever
# asked for it, when the caller knows: the request-driven ones do
with metadata_tracker(user, resource=_resource):
@giohappy
giohappy merged commit a329dc2 into 5.1.x Oct 5, 2026
14 checks passed
@giohappy
giohappy deleted the 14686_51x_metadata_order branch October 5, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed CLA Bot: community license agreement signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata: handler registration order

4 participants