You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG | leverage tofu/terraform always exits 0, even when the binary fails #335
Every leverage tofu / leverage terraform command exits with 0, even when the underlying binary fails.
leverage/modules/tf.py calls tf.run(...) and discards the exit code it returns in _init, _plan, _apply, _output, _destroy, version, format, force-unlock, validate and import. Runner.run returns the code (it does not raise), so nothing propagates it to the process.
Reproduction
With a fake tofu on PATH that exits 1 (or 2), from a layer:
$ leverage tofu plan;echo$?0
$ leverage tofu plan -detailed-exitcode;echo$?# tofu returned 20
$ leverage tofu apply -auto-approve;echo$?# tofu returned 10
Same result for init, destroy, output, and with --layers (every layer runs even after one fails).
Impact
Any CI pipeline running leverage tofu apply / plan reports success when it failed.
plan -detailed-exitcode cannot be used to detect drift.
--layers keeps going after a failing layer (e.g. applies layer B after layer A's apply failed).
Regression introduced in #316 (Docker removal), released in v3.1.0. Before it, every command did exit_code = tf.start_in_layer(...); if exit_code: raise Exit(exit_code). It also contradicts the spec: "if the underlying binary fails, the CLI exits with the same exit code".
aws, kubectl and tfautomv are not affected (they already propagate the code).
Proposed fix
Restore raise Exit(exit_code) on a non-zero exit code for all the commands above.
Prior occurrence: #272 (init did not exit with an error when it failed internally), fixed in 2024. #316 reintroduced it, this time for every tofu/terraform command.
Activity
diego-ojeda-binbash commentedon Nov 13, 2026
Prior occurrence: #272 (
initdid not exit with an error when it failed internally), fixed in 2024. #316 reintroduced it, this time for everytofu/terraformcommand.