Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: value is marked, so must be unmarked first - for loop in output #27375

Closed
mrjosh opened this issue Dec 28, 2020 · 5 comments · Fixed by #27412
Closed

panic: value is marked, so must be unmarked first - for loop in output #27375

mrjosh opened this issue Dec 28, 2020 · 5 comments · Fixed by #27412
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue new new issue not yet triaged

Comments

@mrjosh
Copy link

mrjosh commented Dec 28, 2020

Terraform Version

Terraform v0.14.3

Terraform Configuration Files

output "master_nodes" {
  value = {
    for i in range(length(hcloud_server.control_planes)) :
    hcloud_server.control_planes[i].name => {
      name = hcloud_server.control_planes[i].name
      ip = hcloud_server_network.control_planes[i].ip
      connection = {
        host = hcloud_server.control_planes[i].ipv4_address
      }
    }
  }
  sensitive = true
}

Debug Output

https://gist.github.com/iamalirezaj/6886a2805f82b09078777e2658fc3805

Crash Output

https://gist.github.com/iamalirezaj/6886a2805f82b09078777e2658fc3805

Expected Behavior

Command succeeded

Actual Behavior

panic: value is marked, so must be unmarked first

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

Im using a for loop to create an object of multiple servers in an output!

References

@mrjosh mrjosh added bug new new issue not yet triaged labels Dec 28, 2020
@clement-pruvot
Copy link

Same error with a for_each loop too.

@danieldreier
Copy link
Contributor

Hi! Thank you for reporting this! Based on your errors, I believe that this is probably a valid issue, and in order to hand it off to engineers to be fixed I need to reproduce it locally.

To do that, I have to be able to run this and run it on my workstation without inventing any details in order to be confident we're seeing the same behavior. As-is, the example case you provided has a bunch of variables that I don't have the data for. It would be super helpful if you could replace those with static data or declare variables so I don't have to invent fake data to reproduce your crash case.

@clement-pruvot the same goes for you - you may, or may not be seeing the same underlying bug, and so if you can come up with a simple reproduction case, we can confirm whether the fix we make for the parent issue also fixes the issue you're seeing.

Can you both please restate your reproduction cases such that I can copy-paste it and run it locally? If you need to use providers, this would ideally use the null resource provider rather than a real provider in order to minimize external dependencies.

@danieldreier danieldreier added the waiting for reproduction unable to reproduce issue without further information label Dec 28, 2020
@alisdair
Copy link
Contributor

alisdair commented Jan 5, 2021

@iamalirezaj I'm not sure why you think this output with a for loop is the source of the problem here, but the crash log you supplied doesn't agree with that. Instead, the issue appears to be using variable validation in a module input variable which is bound to a sensitive value.

Reproduction case below, panics with terraform plan:

main.tf

variable "bar" {
  default = "nah"
  sensitive = true
}

module "foo" {
  source = "./foo"
  test = var.bar
}

foo/main.tf:

variable "test" {
  type = string

  validation {
    condition     = var.test != "nope"
    error_message = "Value must not be \"nope\"."
  }
}

@alisdair alisdair added confirmed a Terraform Core team member has reproduced this issue v0.14 and removed waiting for reproduction unable to reproduce issue without further information labels Jan 5, 2021
@alisdair alisdair self-assigned this Jan 5, 2021
@mrjosh
Copy link
Author

mrjosh commented Jan 6, 2021

@alisdair Yeah, i was trying to explain what i was doing when i got this error.
as you can see, i was using hetzner cloud provider and it was a little bit difficult for me to debug the code to see what was actually happen!
Thanks for checking this out

@ghost
Copy link

ghost commented Feb 6, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants