Skip to content

fix (cmd,pkg) : Potential Panic/Crash via Nil Pointer Dereference in Switch Context Command#464

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
aniket866:fix/Nil-Pointer-Dereference
Jun 21, 2026
Merged

fix (cmd,pkg) : Potential Panic/Crash via Nil Pointer Dereference in Switch Context Command#464
Harsh4902 merged 1 commit into
microcks:masterfrom
aniket866:fix/Nil-Pointer-Dereference

Conversation

@aniket866

@aniket866 aniket866 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

If a user runs the context command on a fresh installation without a pre-existing configuration, config.ReadLocalConfig(...) returns nil, nil. The command checks for errors but not for nil values, and proceeds directly to access localCfg.CurrentContext:

localCfg, err := config.ReadLocalConfig(configPath)
errors.CheckError(err)
...
if localCfg.CurrentContext == ctxName {

This causes a runtime nil-pointer dereference panic.

Reason

Standard CLI usability dictates that commands should fail gracefully with a user-friendly message rather than panicking when no configuration is initialized.

image

Closes #462

@github-actions

Copy link
Copy Markdown

👋 @aniket866

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

@aniket866

Copy link
Copy Markdown
Contributor Author

@lbroudoux @Harsh4902
Please review whenver you get time

Comment thread pkg/connectors/container_client.go
Comment thread pkg/connectors/container_client.go
Signed-off-by: aniket866 <iamaniketkumarmaner@gmail.com>
@aniket866 aniket866 force-pushed the fix/Nil-Pointer-Dereference branch from a9d7d7c to a910fc5 Compare June 19, 2026 17:39
@aniket866

Copy link
Copy Markdown
Contributor Author

hi @Harsh4902 I have done the required changes , now PR is ready to be reviewed, do whenever you get time

@aniket866 aniket866 requested a review from Harsh4902 June 19, 2026 17:41

@Harsh4902 Harsh4902 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @aniket866

@Harsh4902 Harsh4902 added component/cli go Pull requests that update go code labels Jun 21, 2026
@Harsh4902 Harsh4902 added this to the Next milestone Jun 21, 2026
@Harsh4902 Harsh4902 merged commit 5941830 into microcks:master Jun 21, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown

🎉 @aniket866

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Potential Panic/Crash via Nil Pointer Dereference in Switch Context Command

2 participants