Skip to content

[Tracking] Complete the set -u hardening (v2.3.0 unbound-variable regressions) #53

Description

@Zordrak

Summary

Enabling set -uo pipefail in v2.3.0 (bin/terraform.sh:8)
exposed several pre-existing unguarded variable references that only crash on
specific, previously-tolerated code paths. This is a tracking issue grouping
the individual defects so they can be resolved together as a single, coherent
"complete the set -u hardening" pass and verified end-to-end.

This tracker is not a separate defect — the actual bugs and their fixes live in
the child issues below.

Child issues

Why group them

All four share a single cause class: set -u was switched on without a full
sweep for references that can be reached while unset. They are distinct root
causes with distinct fixes
, but they interact and are cheapest to fix and
verify as one unit:

Suggested approach

Treat this as one focused hardening PR (or a short series) that:

  1. Fixes Unbound variable access breaks deployment #49 first so the bootstrap path is reachable for testing.
  2. Ensures environment and component are always defined (even if empty) so
    the existing [ -n "${var}" ] presence checks behave, and audits the S3
    path constructions in bootstrap mode (secrets/remote-vars lookups) — these
    arguably should be skipped entirely when bootstrap == 'true'.
  3. Initialises tf_var_file_paths as =() and guards the zero-element
    cat "${tf_var_file_paths[@]}" at bin/terraform.sh:606.
  4. Resolves the shell-in-bootstrap message (Bootstrap with -a shell crashes with "component: unbound variable" under set -u #52), likely by switching to the
    always-set ${component_name}.
  5. Does a final belt-and-braces sweep for any remaining bare ${var}
    references reachable while unset, so we don't file a fifth issue next month.

Verification

After the fixes, the documented README bootstrap workflow (no -e, no -c,
minimal/empty etc/) should run cleanly:

bin/terraform.sh -p myproject -b myproject-tfscaffold -r eu-west-2 --bootstrap -a plan
bin/terraform.sh -p myproject -b myproject-tfscaffold -r eu-west-2 --bootstrap -a apply

…with no unbound variable aborts, and without needing a dummy -- <arg>
workaround.

Related

Individual defects: #49, #50, #51, #52.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions