fix: include error values in init_step_runner log messages#6382
Open
kuishou68 wants to merge 1 commit intorunatlantis:mainfrom
Open
fix: include error values in init_step_runner log messages#6382kuishou68 wants to merge 1 commit intorunatlantis:mainfrom
kuishou68 wants to merge 1 commit intorunatlantis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves operational diagnosability of InitStepRunner by ensuring logged error conditions include the underlying error values (and by raising one log to Warn) so failures around .terraform.lock.hcl handling are actionable in production.
Changes:
- Include
errin the “is file tracked” warning log message. - Promote the lockfile deletion failure log from
InfotoWarnand includedelErrin the message.
Comments suppressed due to low confidence (1)
server/core/runtime/init_step_runner.go:33
- When
common.IsFileTrackedreturns an error,terraformLockFileTrackedwill befalse(seeIsFileTrackedimplementation), so the subsequentif common.FileExists(...) && !terraformLockFileTrackedmay delete.terraform.lock.hcleven though tracking status is unknown. Consider guarding the deletion witherr == nil(or otherwise defaulting to “tracked” on error) to avoid potentially deleting a git-tracked lockfile whengit ls-filesfails.
terraformLockfilePath := filepath.Join(path, lockFileName)
terraformLockFileTracked, err := common.IsFileTracked(path, lockFileName)
if err != nil {
ctx.Log.Warn("Error checking if %s is tracked in %s: %s", lockFileName, path, err)
}
// If .terraform.lock.hcl is not tracked in git and it exists prior to init
// delete it as it probably has been created by a previous run of
// terraform init
if common.FileExists(terraformLockfilePath) && !terraformLockFileTracked {
9a7251f to
e240f7a
Compare
Guard lock file deletion when IsFileTracked returns an error to prevent silent error swallowing in log output. Closes runatlantis#6381 Signed-off-by: Cocoon-Break <54054995+kuishou68@users.noreply.github.com>
e240f7a to
f90f05e
Compare
lukemassa
approved these changes
Apr 11, 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.
Closes #6381
Problem
In
server/core/runtime/init_step_runner.go, two error conditions log a message but silently drop the actual error values from the format string arguments:When
common.IsFileTrackedreturns an error, the log call is:When
utils.RemoveIgnoreNonExistentreturns an error, the log call is:This means operators see a vague log message with no information about the root cause of the failure.
Fix
errto the first log call's format argsdelErrto the second log call's format argsInfotoWarnsince it represents an error condition