Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on context switch #386

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

enrichman
Copy link
Contributor

@enrichman enrichman commented Aug 22, 2024

Ref: rancher/rancher#45340

Switching an empty context will cause a panic.

Added an ErrNoServerSelected error on the FocusedServer() func to force the check of a valid focused server.

@enrichman enrichman requested a review from a team as a code owner August 22, 2024 10:44
@enrichman enrichman changed the title FIx panic on context switch45340 rancher cli panics FIx panic on context switch Aug 22, 2024
@enrichman enrichman self-assigned this Aug 22, 2024
@enrichman enrichman changed the title FIx panic on context switch Fix panic on context switch Aug 22, 2024
alegrey91
alegrey91 previously approved these changes Aug 22, 2024
Copy link

@alegrey91 alegrey91 left a comment

Choose a reason for hiding this comment

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

LGTM

config/config.go Outdated Show resolved Hide resolved
cmd/common.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pmatseykanets pmatseykanets left a comment

Choose a reason for hiding this comment

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

It would be nice to have tests.

@enrichman
Copy link
Contributor Author

Yes, I agree. Not sure if having those just at the FocusedServer() func level make sense though. Add tests on the outer functions is difficult at the moment, without a refactoring.

Next week there will be a discussion about the CLI, so if we will need to develop a bit more on it then we will have some time to clean up the code!

@enrichman enrichman merged commit 11d795b into rancher:main Aug 22, 2024
1 check passed
enrichman added a commit to enrichman/cli that referenced this pull request Aug 22, 2024
* added bool check for missing focused server, fixed panic

* added main branch to FOSSA workflow

* return error instead of bool
enrichman added a commit to enrichman/cli that referenced this pull request Sep 4, 2024
* added bool check for missing focused server, fixed panic

* added main branch to FOSSA workflow

* return error instead of bool
enrichman added a commit that referenced this pull request Sep 4, 2024
* added bool check for missing focused server, fixed panic

* added main branch to FOSSA workflow

* return error instead of bool
enrichman added a commit that referenced this pull request Sep 4, 2024
* added bool check for missing focused server, fixed panic

* added main branch to FOSSA workflow

* return error instead of bool
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] Rancher CLI panics when we try to switch context without any selection
3 participants