Skip to content

feat: throw error on deploy command if build fails and user has --json option #7367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sarahetter
Copy link
Contributor

@sarahetter sarahetter commented Jun 25, 2025

Summary

When a build fails when a user runs netlify deploy --json it currently fails silently. Behaviour can be seen by running:

export DEPLOY_JSON=$(netlify deploy --json)
echo $DEPLOY_JSON

on a project that has exit 1 as its build command.

This PR changes that so we now throw an error like elsewhere in the deploy command, regardless of the --json option

@sarahetter sarahetter requested a review from a team as a code owner June 25, 2025 23:06
Copy link

github-actions bot commented Jun 25, 2025

📊 Benchmark results

Comparing with d81b990

  • Dependency count: 1,105 (no change)
  • Package size: 276 MB (no change)
  • Number of ts-expect-error directives: 399 (no change)

Copy link
Member

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

LGTM

cwd: builder.directory,
env: { NETLIFY_SITE_ID: context.siteId },
}),
).rejects.toThrow('Error while running build')
Copy link
Member

Choose a reason for hiding this comment

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

do we expect the output to be json on failures or no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope don't do that anywhere else

@sarahetter sarahetter enabled auto-merge (squash) June 26, 2025 15:32
@sarahetter sarahetter merged commit 1c0082f into main Jun 26, 2025
47 checks passed
@sarahetter sarahetter deleted the sarahetter/cpla-2772-cli-not-throwing-an-exit-error-code-with-the-json-flag branch June 26, 2025 16:41
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