Skip to content

Problem: Unexpectedly default CLI args for Terraform/OpenTofu Task Templates are used #3879

@tomaszn

Description

@tomaszn

Issue

When a Terraform/OpenTofu task template defines default CLI args (such as ["-target", "my-vm"]), and a user attempts to launch a task from this template—but removes all CLI args in the UI override ("chips"), the task still runs with the original template CLI args. It is impossible to clear the args and run without any, even though the UI allows submitting an empty override.


Steps to Reproduce

  1. Create an OpenTofu Template

    • In Advanced options define CLI args, e.g. ["-target", 'module.my_datacenter.openstack_compute_instance_v2.webserver["000"]']
    • In Prompts enable CLI args.
  2. Launch Task from Template

    • In the pop-up for editing the CLI args, remove all chips so no CLI args remain.
  3. Run the Task


Expected Behavior

  • The task should run with no CLI args or with exactly what the user sets in the override popup—even if that's blank/empty.

Actual Behavior

  • The task still runs using the template’s CLI args (["-target", "my-vm"] in this example), even though the user removed all chips and submitted an empty override.

Impact

Semaphore Project

Installation method

Docker

Database

Postgres

Browser

Firefox

Semaphore Version

v2.18.4^0-7ca373d-1779131288

Ansible Version

Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

Preliminary analysis by GitHub AI

  • In the backend merge logic for CLI args (getTerraformArgs() in services/tasks/LocalJob.go), the code appends the task arg array to the template array. If the override array is empty ([]), the template’s args stay intact.

  • This means "no override" (field unset) and "user cleared the args" (explicit empty) get conflated—the template args are always used unless an override with values is present.

Why This Matters

  • I expected "removing all CLI args" via the UI to actually run the task with no extra CLI args.
  • This can cause the tool to always operate in a way the user wishes to avoid (e.g., too narrow or destructive operations).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions