Skip to content

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

Open
Priyanshubhartistm wants to merge 1 commit into
microcks:masterfrom
Priyanshubhartistm:fix/silent-success-exit-code-bug
Open

fix: replace silent return with os.Exit(1) on auth/config failures#369
Priyanshubhartistm wants to merge 1 commit into
microcks:masterfrom
Priyanshubhartistm:fix/silent-success-exit-code-bug

Conversation

@Priyanshubhartistm
Copy link
Copy Markdown

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>
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: microcks test exits with status 0 on auth/config failure - pipelines silently report "passed" when the test never ran

1 participant