fix: return non 0 with unsuported recipe#1844
Open
vjripoll wants to merge 8 commits into
Open
Conversation
fa99678 to
f404d73
Compare
f404d73 to
9d90cea
Compare
alvarocabanas
approved these changes
Jul 8, 2026
| // For targeted installs, return the error to ensure non-zero exit code | ||
| if len(extractedRecipeNames) > 0 { | ||
| return err | ||
| } |
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.
Description
Fixes exit code behavior when targeted recipe installation fails.
Problem
When users specify a recipe explicitly using -n/--recipe (targeted install), if the installation fails (e.g., unsupported platform, recipe not found), the CLI incorrectly returns exit code 0 (success):
newrelic install -n unsupported-recipe
echo $? # Returns 0 (wrong!)
This happens because the error handling falls through to the shouldInstallCore() block, which is designed for graceful fallback in guided installation mode. It prints a helpful message but doesn't propagate the error, causing the command to exit successfully.
Solution
Add an early return for targeted installs that propagates the error before reaching the fallback logic:
For targeted installs, return the error to ensure non-zero exit code
This ensures:
BEFORE
AFTER