Skip to content

cli: hint when install-runner options are ignored#938

Open
YasharthPanwar-2003 wants to merge 1 commit into
docker:mainfrom
YasharthPanwar-2003:fix-install-runner-existing-options
Open

cli: hint when install-runner options are ignored#938
YasharthPanwar-2003 wants to merge 1 commit into
docker:mainfrom
YasharthPanwar-2003:fix-install-runner-existing-options

Conversation

@YasharthPanwar-2003
Copy link
Copy Markdown

Summary

  • Add a reinstall hint when install-runner finds an existing running Model Runner container
  • Show the hint only when the user explicitly passed --backend or --gpu
  • Preserve the existing “already running” message and return behavior
  • Add focused tests for the new hint-generation logic

Fixes #907

What changed

  • Added commandFlagChanged to check whether a Cobra flag was explicitly changed
  • Added existingRunnerOptionsHint to build the reinstall command hint
  • Updated the existing ctrID != "" branch to print the hint after the current already-running message
  • Added cmd/cli/commands/install_runner_existing_options_hint_test.go

What this does not change

  • Does not automatically reinstall or recreate an existing runner
  • Does not change reinstall-runner behavior
  • Does not change backend selection logic
  • Does not change GPU probing or CUDA/vLLM runtime behavior
  • Does not attempt to fully fix WSL2 CUDA/vLLM execution

Tests added

  • No hint when --backend and --gpu were not explicitly passed
  • Backend-only hint
  • GPU-only CUDA hint
  • Backend + CUDA hint
  • Explicit --gpu none hint
  • Defensive flag-check cases

Validation

  • go test ./cmd/cli/commands -run "TestInstallRunner|TestExistingRunnerOptionsHint|TestCommandFlagChanged" -v
  • go test ./cmd/cli/commands -v`
  • go test ./...
  • make validate-all

Validation details

  • go.mod tidy check passed
  • golangci-lint run ./... passed with 0 issues
  • go test -race ./... passed
  • Shellcheck validation passed
  • .versions is in sync with Dockerfile ARGs

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
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 introduces a mechanism to provide users with a hint command when they attempt to install or start a Model Runner that is already active but with different configuration flags. It includes a new helper function to detect flag changes and comprehensive unit tests for the hint generation logic. Feedback was provided regarding a potential security and correctness issue where user-provided flag values are not properly escaped in the suggested command string, which could lead to issues if values contain spaces or malicious characters.

Comment on lines +266 to +271
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", opts.backend)
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", opts.gpuMode)
}
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.

security-critical critical

Critical

  • The suggested command string is constructed using unvalidated and unescaped user input from flags. This poses a security risk (command injection if a user copy-pastes a malicious string) and a correctness issue if values contain spaces. Values should be properly quoted/escaped for the shell.

Following the Security principle (Repository Style Guide, line 12), input must be handled safely when crossing boundaries, including when displayed back to the user as a suggested command.

Suggested change
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", opts.backend)
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", opts.gpuMode)
}
if backendChanged && opts.backend != "" {
reinstallArgs = append(reinstallArgs, "--backend", fmt.Sprintf("%q", opts.backend))
}
if gpuChanged && opts.gpuMode != "" {
reinstallArgs = append(reinstallArgs, "--gpu", fmt.Sprintf("%q", opts.gpuMode))
}

@@ -0,0 +1,126 @@
package commands
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.

Better if you can put the tests in existing install-runner_test.go file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok , I do that. May you please help me with if the gemini suggested changes to be done in code ?

Copy link
Copy Markdown
Contributor

@sathiraumesh sathiraumesh May 25, 2026

Choose a reason for hiding this comment

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

@YasharthPanwar-2003 if you check the code both of theopts.backend and the opts.gpuMode are validated by predefined sepcs. so it won't be a problem though but for defense in future its better to do the suggestion by gemini here like change to the below


if backendChanged && opts.backend != "" {
		reinstallArgs = append(reinstallArgs, "--backend", fmt.Sprintf("%q", opts.backend))
	}
	if gpuChanged && opts.gpuMode != "" {
		reinstallArgs = append(reinstallArgs, "--gpu", fmt.Sprintf("%q", opts.gpuMode))
	}

Its always important to double check what these analyzers suggest because it sometimes can be wrong. Always try to check whether its the case

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.

and test this feature in local as well :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I dont have NVIDIA gpu cuda , but I tested it over wsl2 Ubuntu 22.04 for cpu only , after the new updation I will test again!

@ericcurtin
Copy link
Copy Markdown
Contributor

@YasharthPanwar-2003 thanks for looking at this, is the bot comment worth fixing?

@ericcurtin
Copy link
Copy Markdown
Contributor

You will need to fix CI also

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]vllm backend doesn't work for wsl2 ubuntu22.04

3 participants