Skip to content

Conversation

lekaf974
Copy link
Contributor

@lekaf974 lekaf974 commented Aug 23, 2025

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

New behavior

~$ ./mesheryctl model generate -f tests/e2e/002-model/fixtures/model-import/valid-model
Error: inside the directory tests/e2e/002-model/fixtures/model-import/valid-model either the model csv or component csv is missing or they are not of write format

…erate subconmad + refactoring to make code more readable

Signed-off-by: lekaf974 <matthieu.evrin@gmail.com>
@github-actions github-actions bot added the component/mesheryctl CLI for Meshery label Aug 23, 2025
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.

Summary of Changes

Hello @lekaf974, 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 refactors the mesheryctl model generate command by introducing a structured approach for model generation from URLs and CSV files. It extracts the generation logic into dedicated generator types, improving code readability and maintainability. Crucially, it also fixes an issue where errors during model generation were not properly propagated, ensuring that failures are now correctly reported.

Highlights

  • Refactoring mesheryctl model generate: The mesheryctl model generate command has been refactored to improve code organization and readability by abstracting model generation logic into distinct types.
  • Improved Error Handling: Errors encountered during model generation, previously suppressed, are now properly returned and propagated, ensuring accurate reporting of failures.
  • Introduction of Generator Types: New ModelGenerator interface, UrlModelGenerator, and CsvModelGenerator structs have been introduced to encapsulate URL-based and CSV-based model generation logic, respectively.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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

@lekaf974 lekaf974 requested review from n2h9 and Copilot August 23, 2025 02:40
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 refactors the model generation logic by introducing a ModelGenerator interface and specific implementations for URL and CSV-based generation. This significantly improves the readability and maintainability of the generate subcommand. The core issue of improper error handling, where errors were logged but suppressed, has been fixed by correctly propagating them. I've added one suggestion to further reduce code duplication in the new CsvModelGenerator.

Copy link

github-actions bot commented Aug 23, 2025

…ve readability and maintaibility

Signed-off-by: lekaf974 <matthieu.evrin@gmail.com>
@lekaf974 lekaf974 changed the title fix(mesheryctl-generate): Fix error not handled properly in model gen… fix(mesheryctl-generate): Fix error not handled properly in model generate subconmad Aug 23, 2025
@lekaf974 lekaf974 requested a review from Darshan174 August 23, 2025 02:54
@@ -48,58 +65,41 @@ mesheryctl model generate --f [URL] -t [path-to-template.json] -r

register, _ := cmd.Flags().GetBool("register")

// Path is a url
if isUrl {
template, _ := cmd.Flags().GetString("template")
Copy link
Contributor

Choose a reason for hiding this comment

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

show error if the temple provided is invalid or empty

Copy link
Contributor Author

@lekaf974 lekaf974 Aug 23, 2025

Choose a reason for hiding this comment

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

this is exactly what we are doing

if template == "" {
	return ErrTemplateFileNotPresent()
}

Copy link
Contributor

Choose a reason for hiding this comment

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

for invalid template?


fileData, err := os.ReadFile(u.TemplateFile)
if err != nil {
return utils.ErrFileRead(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

so this fixes the silent returned error issue right?

}

err = registerModel(fileData, nil, nil, "", "url", u.Url, !u.SkipRegister)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

adding error log after nil would help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is what we do

  return err

for _, f := range filePaths {
*f.data, err = os.ReadFile(f.path)
if err != nil {
return utils.ErrFileRead(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

here as well, logging the error after this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return the error will automatically log it in RunE

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@lekaf974 lekaf974 requested a review from alphaX86 August 26, 2025 22:21
@alphaX86 alphaX86 changed the title fix(mesheryctl-generate): Fix error not handled properly in model generate subconmad fix(mesheryctl-generate): Fix error not handled properly in model generate subcommand Aug 27, 2025
@lekaf974 lekaf974 merged commit 5e268d4 into meshery:master Aug 28, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/mesheryctl CLI for Meshery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mesheryctl] model generate is not handling error properly
3 participants