From 4ee4d1927d8c3f0e8b9b46606bd262b1647032ed Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Fri, 3 Jul 2026 14:38:30 +0000 Subject: [PATCH] mailserver: guard alias filter against short lines with a lazy ternary 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 --- stacks/mailserver/modules/mailserver/main.tf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stacks/mailserver/modules/mailserver/main.tf b/stacks/mailserver/modules/mailserver/main.tf index d1589a8d..f6f15577 100644 --- a/stacks/mailserver/modules/mailserver/main.tf +++ b/stacks/mailserver/modules/mailserver/main.tf @@ -14,10 +14,15 @@ variable "nfs_server" { type = string } locals { _account_set = keys(var.mailserver_accounts) _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", [ for line in local._virtual_lines : line - if !( - length(split(" ", line)) == 2 && + if length(split(" ", line)) != 2 ? true : !( contains(local._account_set, split(" ", line)[0]) && contains(local._account_set, split(" ", line)[1]) && split(" ", line)[0] != split(" ", line)[1]