Skip to content

Bug: workspace template variable default value is not used if no value provided and workspace creation fails #1499

Closed
@kconley-sq

Description

@kconley-sq

OS Information

  • OS: macOS 12.3.1
  • Browser (if applicable): N/A
  • Architecture: arm64
  • coder --version:
Coder v0.5.6+bbb8f83 Thu May 12 17:59:34 UTC 2022
https://github.com/coder/coder/commit/bbb8f836bf5514c9ab67128661ed4909e98a918c

(same Coder version both on CLI and server, but server is Ubuntu 20.04 LTS x86_64)

Steps to Reproduce

  1. Create a workspace template using the aws-linux example
  2. Create a workspace from the Coder CLI using coder create --template="aws-linux" test-defaults
  3. When prompted for var.disk_size, press return without typing any other input
  4. Provide values for the other input variables and confirm the workspace creation when prompted

Expected

The workspace creation should succeed, using the default value for var.disk_size since none was provided when prompted.

Actual

The workspace creation fails with an error describing that the value provided for disk_size is invalid because a number is required. At that point, the workspace is actually in an invalid state such that you are not able to delete it nor create a new workspace with the same name (see #831 (comment)).

Logs

# coder create --template="aws-linux" test-defaults
                                                            
  This template has customizable parameters. Values can be  
  changed after create, but may have unintended side effects
  (like data loss).                                         

var.disk_size
  Specify your disk size (GiB)

> Enter a value: 
var.region
  What region should your workspace live in?

  >  us-west-2 

┌────────────────────────────────────────────────────────────────────────────────┐
│ Workspace Preview                                                              │
├────────────────────────────────────────────────────────────────────────────────┤
│ RESOURCE                             STATUS      ACCESS                        │
├────────────────────────────────────────────────────────────────────────────────┤
│ aws_instance.dev                     ephemeral                                 │
│ └─ dev (linux, amd64)                             coder ssh test-defaults.dev  │
└────────────────────────────────────────────────────────────────────────────────┘
> Confirm create? (yes/no) yes
✔ Queued [433ms]
✔ Setting up [10ms]
⧗  Starting workspace 
  Terraform 1.1.7
  Warning: Argument is deprecated
  Warning: Argument is deprecated
  Error: Invalid value for input variable
  The argument -var="disk_size=..." does not contain a valid value for variable "disk_size": a number is required.
  Error: Invalid operand
  Unsuitable value for left operand: a number is required.
  Error: Invalid operand
  Unsuitable value for left operand: a number is required.
✘ Starting workspace [6115ms]
exit status 1

Metadata

Metadata

Assignees

Labels

apiArea: HTTP API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions