Skip to content

[Fixes #2442] add missing lang in metadata schema build#2449

Open
mattiagiupponi wants to merge 1 commit intomasterfrom
fixes_2442
Open

[Fixes #2442] add missing lang in metadata schema build#2449
mattiagiupponi wants to merge 1 commit intomasterfrom
fixes_2442

Conversation

@mattiagiupponi
Copy link
Copy Markdown

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 addresses a bug where the language parameter was not being passed to the build_schema_instance method during metadata schema construction. By including the lang parameter, the system can now correctly generate language-specific metadata schemas, resolving potential localization issues and fixing issue #2442.

Highlights

  • Metadata Schema Building: The build_schema_instance function now correctly receives the lang parameter, ensuring that metadata schemas are built with the appropriate language context.

🧠 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.

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.

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
Copy Markdown

@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 updates the metadata view in geonode_mapstore_client/views.py to pass the language parameter to build_schema_instance, enabling language-aware metadata generation. Additionally, a newline character was added at the end of the file. A critical issue was identified where the lang variable, derived from get_language_from_request, could be None, leading to a TypeError when sliced. A suggestion was provided to handle this by using a fallback language to prevent unhandled exceptions.

schema = metadata_manager.get_schema(lang)
resource = ResourceBase.objects.get(pk=pk)
schema_instance = metadata_manager.build_schema_instance(resource)
schema_instance = metadata_manager.build_schema_instance(resource, lang)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

While passing lang to build_schema_instance is correct, the way lang is obtained on line 58 is unsafe. get_language_from_request can return None, and None[:2] will raise a TypeError, causing an unhandled exception (500 error). It would be safer to handle this case by providing a fallback language.

I suggest changing line 58 to:

    lang = (get_language_from_request(request) or settings.LANGUAGE_CODE)[:2]

This ensures that lang always has a string value before slicing.

@mattiagiupponi mattiagiupponi marked this pull request as ready for review March 25, 2026 11:07
@mattiagiupponi mattiagiupponi requested a review from etj March 25, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant