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

r/tfe_workspace: Fix panic when trigger_prefixes = [""] #1214

Merged
merged 2 commits into from
Jan 13, 2024

Conversation

nfagerlund
Copy link
Member

@nfagerlund nfagerlund commented Jan 12, 2024

Description

A customer reported this panic via support. Sebastian clued me in that this is an extremely cursed known behavior in sdkv2, where it munges a list of strings containing one empty string into a list containing a single nil, so you must do a type assert on the inner elements.

Note that the Update function already did exactly this (around line 655 or so)! So there was no panic if you changed trigger_prefixes to the fatal value after the resource already existed.

Remember to:

Testing plan

Config:

provider "tfe" {
  hostname = <YOURS>
}

resource "tfe_workspace" "ex-splodo" {
  auto_apply                    = true
  file_triggers_enabled         = true
  name                          = "jan24-trigger-prefixes-panic-repro"
  organization                  = <YOURS>
  queue_all_runs                = true
  structured_run_output_enabled = true
  terraform_version             = "1.5.1"
  trigger_prefixes              = [""] # <-- RIGHT HERE, THIS IS THE GUY
}

Try to create the resource with a tf apply; should panic as soon as you say "yes" after the plan.

External links

Output from acceptance tests

I'm internal, just check CI.

A customer reported this panic via support. Sebastian clued me in that this is
an extremely cursed known behavior in sdkv2, where it munges a list of strings
containing one empty string into a list containing a single nil, so you must do
a type assert on the inner elements.

Note that the Update function already did exactly this (around line 655 or so)!
So there was no panic if you changed trigger_prefixes to the fatal value after
the resource already existed.
@nfagerlund nfagerlund requested a review from a team as a code owner January 12, 2024 23:21
@nfagerlund nfagerlund merged commit aee014e into main Jan 13, 2024
9 checks passed
@nfagerlund nfagerlund deleted the nf/jan24-panic-empty-trigger-prefixes branch January 13, 2024 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants