Skip to content

Conversation

@parthivsaikia
Copy link
Contributor

Description

This PR updates the ArtifactHub generator to sanitize upstream version strings. Specifically, it uses strings.TrimPrefix to remove the leading v (e.g., converting v2022.06.14 to 2022.06.14) before assigning it to the model version. This ensures compliance with the strict Semantic Versioning checks enforced by the Masterminds/semver library and resolves validation errors for valid upstream charts.

This PR fixes #843

Notes for Reviewers

Verified locally that the fix properly strips the prefix.

The change is isolated to generators/artifacthub/package.go.

Signed commits

  • Yes, I signed my commits.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @parthivsaikia, 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 an issue where version strings from ArtifactHub, when prefixed with a 'v' (e.g., "v2022.06.14"), failed strict semantic versioning validation. By implementing a TrimPrefix operation, the generator now correctly processes these versions, preventing validation errors for otherwise valid upstream charts and improving data consistency.

Highlights

  • Semantic Versioning Compliance: Updated the ArtifactHub generator to sanitize upstream version strings by removing the leading 'v' prefix, ensuring compliance with strict semantic versioning checks enforced by the Masterminds/semver library.
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 an important issue with semver compliance for versions from ArtifactHub by removing the 'v' prefix. The change is straightforward and uses strings.TrimPrefix effectively. My main feedback is regarding testing. While the fix itself is correct, it's not covered by automated tests. I've added a comment suggesting the addition of unit tests to ensure this fix is robust and to prevent future regressions. This will improve the overall quality and maintainability of the code.

}
comp.Model.Metadata.AdditionalProperties["source_uri"] = pkg.ChartUrl
comp.Model.Version = pkg.Version
comp.Model.Version = strings.TrimPrefix(pkg.Version, "v")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly sanitizes the version string. However, there are no automated tests to verify this fix and prevent future regressions.

The existing tests in package_test.go do not seem to cover this logic, as the AhPackage structs used for testing don't have the Version field populated.

Please consider adding a unit test for the GenerateComponents method that specifically verifies the version string sanitization for different cases, such as:

  • Version with a v prefix (e.g., v1.2.3)
  • Version without a v prefix (e.g., 1.2.3)
  • Date-based versions with a v prefix (e.g., v2022.06.14)
  • An empty version string

Adding tests will ensure the stability of this fix. Note that GenerateComponents might need some refactoring to be more easily unit-testable, for example by mocking its dependency on manifests.GetCrdsFromHelm.

@ritesh-karankal
Copy link

Thank you for your contribution! @parthivsaikia 🎉

Let's discuss this PR during the Meshery Development Meeting today.
Please add it as an agenda item to the meeting minutes, including any related topics (issues, enhancements, or blockers) you'd like to cover.

Meshery Development Meeting | December 10th, 2025
Minutes 📝
Meeting ⏰ 10 AM CT | 8:30 PM IST

Copy link
Member

@leecalcote leecalcote left a comment

Choose a reason for hiding this comment

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

@parthivsaikia, thanks for this. Will you provide numbers showing the before and after here? I'm concerned that while this change will be helpful to some models that it will be detrimental to others...

@parthivsaikia
Copy link
Contributor Author

@leecalcote There are total 5 models affected by this change. Those are:

  1. opscenter-core
  2. opscenter-config
  3. bytebuilders-crds
  4. grafana-ui-server
  5. ui-presets

And this change doesn't introduce any detrimental effect to the other models.

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.

[Bug] Artifact Hub generator fails validation on version strings with 'v' prefix

3 participants