Skip to content

fix: return non 0 with unsuported recipe#1844

Open
vjripoll wants to merge 8 commits into
mainfrom
fix-return-non-0-code
Open

fix: return non 0 with unsuported recipe#1844
vjripoll wants to merge 8 commits into
mainfrom
fix-return-non-0-code

Conversation

@vjripoll

@vjripoll vjripoll commented May 13, 2026

Copy link
Copy Markdown
Contributor

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

  if len(extractedRecipeNames) > 0 {
      return err
  }

This ensures:

  • Targeted installs (-n recipe-name): Exit with non-zero code on failure ✅
  • Guided installs (no -n flag): Keep graceful fallback behavior ✅

BEFORE

Screenshot 2026-06-03 at 15 29 51

AFTER

Screenshot 2026-06-03 at 18 34 05

@vjripoll vjripoll force-pushed the fix-return-non-0-code branch from fa99678 to f404d73 Compare June 3, 2026 09:30
@vjripoll vjripoll marked this pull request as ready for review June 3, 2026 09:41
@vjripoll vjripoll force-pushed the fix-return-non-0-code branch from f404d73 to 9d90cea Compare June 3, 2026 10:07

@alvarocabanas alvarocabanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

// For targeted installs, return the error to ensure non-zero exit code
if len(extractedRecipeNames) > 0 {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

2 participants