Flagsmith / terraform-provider-flagsmith

Flagsmith Terraform Provider
Mozilla Public License 2.0
5 stars 2 forks source link

Attribute feature_state_value.string_value Leading and trailing whitespace is not allowed #144

Closed noah-troncoso closed 4 months ago

noah-troncoso commented 4 months ago

I updated the Flagsmith provider from 0.5.1 to 0.7.0 and now I get this error:

Error: Invalid Attribute Value Match
│
│   with flagsmith_feature_state.einsteinrecs_sendevents_yolo,
│   on featureflag-states-yolo.tf line 131, in resource "flagsmith_feature_state" "einsteinrecs_sendevents_yolo":
│  131: resource "flagsmith_feature_state" "einsteinrecs_sendevents_yolo" {
│
│ Attribute feature_state_value.string_value Leading and trailing whitespace is not allowed, got:

The resource in question looks like this:

resource "flagsmith_feature_state" "einsteinrecs_sendevents_yolo" {
  enabled         = true
  environment_key = local.environment_keys.yolo
  feature_id      = flagsmith_feature.einsteinrecs_sendevents.id
  feature_state_value = {
    type         = "unicode"
    string_value = ""
  }
}

It seems to be failing because of the empty string_value, which the documentation says is acceptable.

It looks like this has to do with the change in this PR:

https://github.com/Flagsmith/terraform-provider-flagsmith/commit/ff955e429f0556035295616a9d1735f43708e2e9#diff-44a743db94f8f4f2a687c1e9ff96d4c28682cfb086ac11f7c301a49f98e40c28

There is no test here for an empty string, so I can see how this got missed.

matthewelwell commented 4 months ago

Thanks for raising this @noah-troncoso . We will look into this, but equally if you'd like to submit a PR we'd be happy to receive it. Thanks!

noah-troncoso commented 4 months ago

@matthewelwell I could take a stab at it. Only thing I'm not sure about is how to run the tests. The README says I need these variables:

FLAGSMITH_MASTER_API_KEY
FLAGSMITH_ENVIRONMENT_KEY
FLAGSMITH_ENVIRONMENT_ID
FLAGSMITH_FEATURE_ID
FLAGSMITH_PROJECT_UUID

but what instance is it pointing to? Am I expected to be running flagsmith locally? Also, there isn't a contributions doc or anything. Do I need to create a fork?

rolodato commented 4 months ago

@noah-troncoso No need to run Flagsmith locally - by default the provider points to public Flagsmith, so you can set it up with your own API key and environment details: https://github.com/Flagsmith/terraform-provider-flagsmith/blob/36b042476b9920f0bb5b89e211e026750e491e52/flagsmith/provider.go#L17

You can run the acceptance tests with make testacc as mentioned in the README: https://github.com/Flagsmith/terraform-provider-flagsmith/tree/main?tab=readme-ov-file#developing-the-provider

You should create a fork if you want to send a pull request to this repo, since you do not have write access for it. Thanks!

noah-troncoso commented 4 months ago

Created a PR

gagantrivedi commented 4 months ago

Released here: https://github.com/Flagsmith/terraform-provider-flagsmith/releases/tag/v0.8.0