From 0fbe4daab2063360b69aaa4cc61a4fadcf0f51c4 Mon Sep 17 00:00:00 2001 From: Diogenes Fernandes Date: Wed, 15 Apr 2026 19:40:12 -0300 Subject: [PATCH] fix: drop the success behavior for -detailed-exitcode==2 Signed-off-by: Diogenes Fernandes --- dist/index1.js | 11 +++++------ wrapper/tofu.js | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dist/index1.js b/dist/index1.js index 8b21fc5..54a58d7 100755 --- a/dist/index1.js +++ b/dist/index1.js @@ -30971,15 +30971,14 @@ async function checkTofu () { setOutput('stderr', stderr.contents); setOutput('exitcode', exitCode.toString(10)); - if (exitCode === 0 || exitCode === 2) { - // A exitCode of 0 is considered a success - // An exitCode of 2 may be returned when the '-detailed-exitcode' option - // is passed to plan. This denotes Success with non-empty - // diff (changes present). + if (exitCode === 0) { return; } - // A non-zero exitCode is considered an error + // Any non-zero exitCode is treated as a failure, including exitCode 2 from + // `plan -detailed-exitcode` (success with a non-empty diff). Previously 2 was + // treated as success, but that hid the signal users opt into `-detailed-exitcode` + // to receive. setFailed(`OpenTofu exited with code ${exitCode}.`); })(); diff --git a/wrapper/tofu.js b/wrapper/tofu.js index 60272c4..39f9431 100755 --- a/wrapper/tofu.js +++ b/wrapper/tofu.js @@ -44,14 +44,13 @@ async function checkTofu () { setOutput('stderr', stderr.contents); setOutput('exitcode', exitCode.toString(10)); - if (exitCode === 0 || exitCode === 2) { - // A exitCode of 0 is considered a success - // An exitCode of 2 may be returned when the '-detailed-exitcode' option - // is passed to plan. This denotes Success with non-empty - // diff (changes present). + if (exitCode === 0) { return; } - // A non-zero exitCode is considered an error + // Any non-zero exitCode is treated as a failure, including exitCode 2 from + // `plan -detailed-exitcode` (success with a non-empty diff). Previously 2 was + // treated as success, but that hid the signal users opt into `-detailed-exitcode` + // to receive. setFailed(`OpenTofu exited with code ${exitCode}.`); })();