Skip to content

fix(promote): exit 0 for auto-promote-only failures#15448

Open
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-ryuqzvlokvrx
Open

fix(promote): exit 0 for auto-promote-only failures#15448
Alizter wants to merge 1 commit into
ocaml:mainfrom
Alizter:push-ryuqzvlokvrx

Conversation

@Alizter

@Alizter Alizter commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Teach the build error collection path to distinguish promotion-only failures from real build failures when auto-promotion is enabled.

Diff actions still report errors internally so their diagnostics are printed, but if every collected error is an auto-promoted diff, the CLI exits successfully after finalizing the promotions. Non-promotable diffs and real build/action failures continue to exit non-zero.

The result-producing build path remains conservative: if a command such as dune exec --auto-promote promotes a dependency diff before producing its requested result, it still exits non-zero for that run and succeeds after the next run reaches a fixpoint.

Related Issue and Motivation

dune build --auto-promote and commands such as dune fmt could successfully promote generated changes while still exiting with status 1, forcing callers to wrap them in || true.

This keeps successful auto-promotion distinct from actual failures, including formatter failures such as ocamlformat being unable to parse a source file.

Fixes #785

Checklist

  • Tests added, if applicable.
  • Change log entry added for any user-facing changes.
  • Documentation added for any user-facing changes.

@Alizter Alizter self-assigned this Jul 8, 2026
Signed-off-by: Ali Caglayan <alizter@gmail.com>
@Alizter Alizter force-pushed the push-ryuqzvlokvrx branch from f7f5b6f to fbf6d22 Compare July 8, 2026 19:36
@Alizter Alizter marked this pull request as ready for review July 8, 2026 20:25
@Alizter Alizter requested a review from rgrinberg July 8, 2026 20:25
let run_change loc ~patch_back ~will_promote (mode : Diff.Mode.t) = function
| Message { source_file; messages } ->
User_error.raise
?promotion:(Option.some_if will_promote (promotion source_file))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it intentional that we're changing an error message? Why do we need to do that?

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.

Exit with code 0 when using —auto-promote

2 participants