Skip to content

fix: replace silent return with os.Exit(1) on auth/config failures - #369

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
Priyanshubhartistm:fix/silent-success-exit-code-bug
May 21, 2026
Merged

Harsh4902 merged 1 commit into
microcks:masterfrom
Priyanshubhartistm:fix/silent-success-exit-code-bug

Conversation

@Priyanshubhartistm

Copy link
Copy Markdown
Contributor

Problem

In cmd/test.go, cmd/import.go, cmd/importDir.go, and cmd/importURL.go, several error branches inside the local-config path used plain return statements instead of os.Exit(1):

  • config.ReadLocalConfig() failure
  • localConfig == nil (no login session)
  • connectors.NewClient() failure
  • ValidationError from ImportDirectory

Since Cobra treats a normal Run return as success, the process exited with status 0 even when auth/config initialization failed. This caused CI/CD pipelines to report false-positive success - the command printed an error message but the pipeline saw a green exit code and continued.

Changes

Replaced every silent return in these error branches with os.Exit(1) across all four affected files. No user-visible messages were changed.

Scenario Before After
Missing/corrupt config file exit 0 ❌ exit 1 ✅
No login session (localConfig == nil) exit 0 ❌ exit 1 ✅
NewClient() failure exit 0 ❌ exit 1 ✅
ValidationError from ImportDirectory exit 0 ❌ exit 1 ✅

Files Changed

Commands cmd/test.go, cmd/import.go, cmd/importDir.go, and
cmd/importURL.go used plain return statements inside error branches
(config read failure, nil localConfig, NewClient failure). Because
Cobra treats a normal Run return as success, the process exited with
status 0, causing CI/CD pipelines to report false-positive success.

Replace every such return with os.Exit(1) so that:
- missing/corrupt config file → exit 1
- missing login session (localConfig == nil) → exit 1
- client initialisation failure (NewClient) → exit 1
- ValidationError from ImportDirectory → exit 1

No user-visible messages were changed.

Fixes microcks#361

Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
@Harsh4902 Harsh4902 added this to the Next milestone May 21, 2026
@Harsh4902 Harsh4902 added component/cli go Pull requests that update go code labels May 21, 2026

@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 @Priyanshubhartistm for contribution.

@Harsh4902
Harsh4902 merged commit 93b91f9 into microcks:master May 21, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 @Priyanshubhartistm

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 🙌

@Priyanshubhartistm

Copy link
Copy Markdown
Contributor Author

@Harsh4902 Thank you so much for the review and merge

This branch was previously deployed

1 inactive deployment
Build — a696dc67 Deployed May 21, 2026 by Priyanshubhartistm via build-verify-package #428
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.

Bug: microcks test exits with status 0 on auth/config failure - pipelines silently report "passed" when the test never ran

2 participants