mailserver: guard alias filter against short lines with a lazy ternary
Some checks failed
ci/woodpecker/push/default Pipeline was canceled

CI pipeline 469 failed with 'Invalid index' on the postfix_virtual alias
filter: terraform only short-circuits &&/|| from v1.6, and the older
terraform in the infra-ci image still evaluated split(" ", line)[1] for
the blank and comment lines that have been in extra/aliases.txt since the
plans@ block. The devvm's newer terraform short-circuits, which is why the
local apply of the same commit passed. A conditional expression is lazy on
every terraform version, so move the length guard into a ternary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Viktor Barzin 2026-07-03 14:38:30 +00:00
parent 68b9858eff
commit 4ee4d1927d

View file

@ -14,10 +14,15 @@ variable "nfs_server" { type = string }
locals { locals {
_account_set = keys(var.mailserver_accounts) _account_set = keys(var.mailserver_accounts)
_virtual_lines = split("\n", format("%s%s", var.postfix_account_aliases, file("${path.module}/extra/aliases.txt"))) _virtual_lines = split("\n", format("%s%s", var.postfix_account_aliases, file("${path.module}/extra/aliases.txt")))
# NOTE: the length guard must live in a ternary, not a leading `&&` operand.
# Terraform only short-circuits && / || from v1.6 on the older terraform
# pinned in the infra-ci image, `split(" ", line)[1]` was still evaluated
# for blank/comment lines and failed the whole plan with "Invalid index"
# (first hit by CI pipeline #469, 2026-07-03). A conditional expression is
# lazy on every terraform version.
postfix_virtual = join("\n", [ postfix_virtual = join("\n", [
for line in local._virtual_lines : line for line in local._virtual_lines : line
if !( if length(split(" ", line)) != 2 ? true : !(
length(split(" ", line)) == 2 &&
contains(local._account_set, split(" ", line)[0]) && contains(local._account_set, split(" ", line)[0]) &&
contains(local._account_set, split(" ", line)[1]) && contains(local._account_set, split(" ", line)[1]) &&
split(" ", line)[0] != split(" ", line)[1] split(" ", line)[0] != split(" ", line)[1]