Skip to content

Conversation

@FalcoSuessgott
Copy link
Contributor

@FalcoSuessgott FalcoSuessgott commented Oct 12, 2025

rel. #868 (comment)

> go run cli/cmd/kagent/*.go version
{"backend_version":"unknown","build_date":"unknown","git_commit":"none","kagent_version":"dev"}

kagent versions portforwarding differs now to the other subcommands, perhaps we should just change Stop() to:

func (p *PortForward) Stop() {
  if p == nil {
    return 
  }

	p.cancel()

	if p.cmd.Process != nil {
		p.cmd.Process.Kill() //nolint:errcheck
	}
}

Copilot AI review requested due to automatic review settings October 12, 2025 04:42
Copy link
Contributor

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.

Pull Request Overview

This PR fixes a bug in the kagent main function where port-forwarding would be stopped even when it failed to initialize properly. The fix ensures port-forwarding cleanup only occurs when the connection is successfully established.

  • Only defer pf.Stop() when cli.NewPortForward succeeds
  • Prevents potential nil pointer dereference or unnecessary cleanup operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Tom Morelly <tom.morelly@clearroute.io>
@EItanya EItanya merged commit 3515602 into kagent-dev:main Oct 15, 2025
16 checks passed
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.

2 participants