fix: replace silent return with os.Exit(1) on auth/config failures#369
Open
Priyanshubhartistm wants to merge 1 commit into
Open
fix: replace silent return with os.Exit(1) on auth/config failures#369Priyanshubhartistm wants to merge 1 commit into
Priyanshubhartistm wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
cmd/test.go,cmd/import.go,cmd/importDir.go, andcmd/importURL.go, several error branches inside the local-config path used plainreturnstatements instead ofos.Exit(1):config.ReadLocalConfig()failurelocalConfig == nil(no login session)connectors.NewClient()failureValidationErrorfromImportDirectorySince Cobra treats a normal
Runreturn 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
returnin these error branches withos.Exit(1)across all four affected files. No user-visible messages were changed.localConfig == nil)NewClient()failureValidationErrorfromImportDirectoryFiles Changed
cmd/test.gocmd/import.gocmd/importDir.gocmd/importURL.goFixes Bug: microcks test exits with status 0 on auth/config failure - pipelines silently report "passed" when the test never ran #361