Skip to content

e2e: the remediation guard writes its argument to a global in the caller's shell #3774

Description

helmrelease_has_remediation_cycle in hack/e2e-chainsaw/_lib/remediation-guard.sh assigns its argument to a global:

helmrelease_has_remediation_cycle() {
    statuses="$1"

Line 26 on main, and the only assignment in the file that is not declared local. The file is sourced rather than executed, so the function body runs in the caller's shell and this silently overwrites whatever the caller was keeping in statuses.

Nothing is broken today. The single caller in hack/e2e-chainsaw/_lib/run-kubernetes.sh reads the history into history_statuses, and statuses does not appear anywhere in that file, so the names do not currently collide.

The reason to fix it anyway is the shape of the collision rather than its present absence. run-kubernetes.sh is a 2400-line shared shell sourced by the heavy suites; a future local named statuses anywhere in it would be clobbered by a call to this guard, and the failure would be silent, delayed, and would look like a bug in whatever code read the variable afterwards rather than in the guard that overwrote it. A one-word fix now costs nothing; the same fix after a collision costs whoever has to find it.

local statuses is enough. local is not in POSIX, but the file already targets shells that provide it (the suites run under bash and the helper is exercised by hack/remediation-guard.bats), and dash supports it too.

Worth a pass over the other _lib/ helpers while touching this, since the same sourcing pattern applies to all of them.

Activity

  1. added
    kind/cleanupCategorizes issue or PR as related to cleanup of code, process, or technical debt
    triage/acceptedIndicates an issue is ready to be actively worked on
    priority/backlogGeneral backlog priority. Lower than priority/important-longterm
    and removed
    kind/bugCategorizes issue or PR as related to a bug
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Sep 23, 2026
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

    area/testingIssues or PRs related to testing (e2e, bats, unit tests)kind/cleanupCategorizes issue or PR as related to cleanup of code, process, or technical debtpriority/backlogGeneral backlog priority. Lower than priority/important-longtermtriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions