Fix deploy command to exit non-zero on deployment failure#119
Merged
Conversation
The `deployments deploy` handler printed a failure message but returned normally when the deployment failed, so the process exited 0 and the audit log recorded status "success". Throw an error on non-success so the failure propagates to the exit code and audit log via the existing error handling. Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude <claude@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
=======================================
Coverage 99.45% 99.45%
=======================================
Files 235 235
Lines 4031 4033 +2
Branches 1016 1031 +15
=======================================
+ Hits 4009 4011 +2
Misses 22 22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Streamed log chunks have no trailing newline, so the success/failure message was printed on the same line as the last log line. Emit a separating newline on stdout when streaming. Co-authored-by: Claude <claude@anthropic.com>
Vite bundled pino and resolved its browser build, which routes log output to the console via console.log. This printed the audit entry object to stdout after every write command. Externalize pino so Node resolves its real node build at runtime and logs go to the audit file. Co-authored-by: Claude <claude@anthropic.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
forge deployments deploy(with or without--stream) always exited0and recordedstatus: "success"in the audit log, even when the deployment failed on the server (e.g. a deploy script exiting1).Root cause
The failure was detected correctly —
deploySiteAndWait()returnsstatus: "failed"and the handler printed✗ Deployment failed …— but the handler then returned normally instead of throwing. As a result:command-routerwrite wrapper never hit itscatch, so it loggedstatus: "success"to the audit log.runCommand→handleError, so the process exited with the default code0.Both symptoms stem from the same missing throw. (Note: the audit log's
statusis control-flow-derived — "did the handler throw" — and is independent of the deployment's ownresult.data.status.)Fix
Throw an error on non-success in the deploy handler. This routes through the existing machinery:
command-routercatch → audit log recordsstatus: "error"runCommand→handleError→process.exit(1)The deployment log is now emitted before the throw (in non-stream mode) so failure output is still shown. No changes needed in
command-routerordeploy-and-wait— they already do the right thing once the handler stops swallowing the failure.Tests
process.exit(1)and that the message goes to stderr.🤖 Generated with Claude Code