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

Apply error: "The fallthrough variation can't be deleted because no off variation is set" #92

Closed
bschaeffer opened this issue Apr 13, 2022 · 2 comments

Comments

@bschaeffer
Copy link

bschaeffer commented Apr 13, 2022

Version: 2.5.0

I am not really sure what this error means:

The fallthrough variation can't be deleted because no off variation is set

Essentially we have three variations defined like so (lines omitted for clarity):

resource "launchdarkly_feature_flag" "flag" {
  variation_type = "string"
  variations {
    value       = "one"
  }
  variations {
    value       = "two"
  }
  variations {
    value       = "three"
  }
  defaults {
    on_variation  = 2
    off_variation = 2
  }
}

We are removing two, but making three the default, so we get a plan like this:

~ resource "launchdarkly_feature_flag" "flag" {
      ~ defaults {
          ~ off_variation = 2 -> 1
          ~ on_variation  = 2 -> 1
        }

      ~ variations {
          ~ value       = "two" -> "three"
        }
      - variations {
          - value       = "three"
        }
        # (2 unchanged blocks hidden)
    }

And we applying we get this error:

╷
│ Error: failed to update flag "flag" in project "default": 400 Bad Request: {"code":"invalid_request","message":"The fallthrough variation can't be deleted because no off variation is set"}
│ 

What do we do here?

@sloloris
Copy link
Member

Hi @bschaeffer!

Unfortunately, this is by design. I've filed a ticket internally to update the rather unhelpful error message, but essentially what is happening here is that there is an existing environment configuration that is still referencing the index 2 variation as a fallthrough. We use updates to the global flag configuration to inform future environment configurations only, which is why you are hitting this error.

If you have environment configurations set up in Terraform, you will want to run through and check them for reference to the index 2 variation and update those together with your global flag update to delete the variation. If they are not configured in Terraform, you will unfortunately have to update them manually from the flag targeting page in each individual environment before applying your global launchdarkly_feature_flag changes again. If you have too many environments configured with this flag for this to be feasible and you are okay with otherwise losing all your environment-specific flag configurations, a nuclear option you could consider is deleting the flag entirely and then recreating it.

I'm so sorry that there isn't a better solution to this. I hope it doesn't cause too much of an inconvenience.

@bschaeffer
Copy link
Author

That makes sense to me. I did end up going with the nuclear option but I could have probably tried to track the offending config down.

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

No branches or pull requests

2 participants