Merged
Conversation
mcncl
reviewed
Mar 30, 2026
4867968 to
3d12860
Compare
matthewborden
commented
Mar 30, 2026
mcncl
reviewed
Mar 30, 2026
This introduces `cmd/preflight.Result` to classify the final preflight `build.State` and return typed CLI errors instead of a generic `fmt.Errorf` for every non-passing result. Previously `bk preflight` ended by returning plain string errors such as `preflight build failed`. `internal/errors/handler.go` treated those the same as any other generic failure, so scripts could not distinguish a completed failed build from an active failure, an incomplete build, or an unknown result. With this change, `Result.Error()` maps preflight outcomes onto dedicated error categories and `internal/errors/handler.go` assigns stable exit codes for each one: | `build.State` | Exit code | Meaning | | --- | ---: | --- | | `passed` | `0` | Successful preflight | | `failed` | `9` | Terminal preflight failure | | `canceled` | `9` | Terminal preflight failure | | `skipped` | `9` | Terminal preflight failure | | `not_run` | `9` | Terminal preflight failure | | `failing` | `10` | Active preflight failure | | `scheduled` | `11` | Incomplete preflight | | `running` | `11` | Incomplete preflight | | `blocked` | `11` | Incomplete preflight | | `canceling` | `11` | Incomplete preflight | | any other state | `12` | Unknown preflight result | This keeps `bk preflight` on the shared CLI error-handling path while giving preflight-specific prefixes, messages, and automation-friendly exit codes. Amp-Thread-ID: https://ampcode.com/threads/T-019d3d79-37bd-700b-8052-34e00ab1e618 Co-authored-by: Amp <amp@ampcode.com>
To seperate cleanup from results
16acdc6 to
5fa7896
Compare
mcncl
approved these changes
Mar 31, 2026
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.
This introduces specific exit codes for preflight builds. This only currently considers the build state, it doesn't use failed jobs to determine the exit status yet, since preflight isn't currently aware of retries and wouldn't go from failure back to success, when a retry succeed. This uses the
failingstate, as a proxy for calculating retried jobs. We can enrich exit code10with failed jobs or tests.Result.Error()maps preflight outcomes onto dedicated error categories andinternal/errors/handler.goassigns stable exit codes for each one:build.Statepassed0failed9canceled9skipped9not_run9failing10scheduled11running11blocked11canceling1112Control-C during the watch loop exits with exit code 128 using the existing
ExitCodeUserAbortedError.