Skip to content

Conversation

@sijandh35
Copy link
Contributor

Fixes #13928

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.

@sijandh35 sijandh35 self-assigned this Feb 3, 2026
@cla-bot cla-bot bot added the cla-signed CLA Bot: community license agreement signed label Feb 3, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sijandh35, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue where newly created resources were not consistently generating a search index, leading to them being unsearchable. The core change involves enhancing the resource update mechanism to infer and apply default metadata (title and abstract) when explicit metadata is absent. This ensures that the metadata manager always has sufficient information to create the necessary ResourceIndex, thereby guaranteeing that all resources are properly indexed and discoverable. A new test case has also been added to validate this behavior.

Highlights

  • Fix Missing Search Index: Addresses issue Missing index records when creating a resource #13928 by ensuring that a ResourceIndex is always created for new resources, even when no explicit metadata (jsoninstance) is provided during creation or update.
  • Default Metadata Inference: Introduces a new utility function infer_default_metadata that generates a default title and abstract for resources if they are not explicitly provided. This ensures that the metadata manager always has data to process for indexing.
  • Resource Manager Update Logic: Modifies the resource_manager.update method to utilize the newly introduced infer_default_metadata function. If jsoninstance is missing from the custom parameters, default metadata is now inferred and used to update the schema instance.
  • New Test Case: Adds a new test test_resource_index_created to geonode/base/api/tests.py to verify that a ResourceIndex object is successfully created for a resource after it is created and updated.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • geonode/base/api/tests.py
    • Imported ResourceIndex model.
    • Added test_resource_index_created to verify the creation of a ResourceIndex for new resources.
  • geonode/resource/manager.py
    • Imported infer_default_metadata from geonode.resource.utils.
    • Modified the update method to call infer_default_metadata if jsoninstance is not provided, ensuring default metadata is used for schema instance updates.
  • geonode/resource/utils.py
    • Added a new function infer_default_metadata to generate a default title and abstract for a resource based on available attributes.
Activity
  • The pull request was opened by sijandh35 to address issue Missing index records when creating a resource #13928.
  • The author has completed most of the checklist items, indicating a thorough preparation of the PR.
  • New unit tests have been added to cover the changes, specifically for verifying resource index creation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug where search indexes were not being created for new resources by inferring and using default metadata during resource updates. However, the implementation introduces a security vulnerability by performing metadata updates without a user context (user=None), bypassing permission checks and allowing basic edit permissions to modify restricted fields such as approval and publication status. Furthermore, the update method has an existing critical Path Traversal vulnerability via the xml_file parameter that requires attention. The changes include a new test case, and a suggestion has been made to refactor a new helper function for improved readability.

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.

Missing index records when creating a resource

2 participants