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

cannot unmarshal string into Go struct field Yaxis.min of type float64 after upgrading to 0.10.3 #19

Closed
RodrigoBerto opened this issue Sep 14, 2017 · 11 comments
Labels

Comments

@RodrigoBerto
Copy link

RodrigoBerto commented Sep 14, 2017

Running terraform plan or apply over existent terraform datadog timeboards resulted in a json: cannot unmarshal string into Go struct field Yaxis.min of type float64 error

Note that despite the error is happening with terraform v0.10.3, I was able to push changes to datadog with this version of terraform until 31/08. But since early September, it has started to fail with that error.

Deleting existent terraform.state and re running plan or apply using the same timeboard configuration works. But doing this will duplicate information in ddog as it will recreate all resources.

The following is how the graph looks atm:

    title = "graph title"
    viz = "timeseries"
    autoscale = true
    precision = "3"
    request {
      q = "the-query"
      type = "area"
      style {
        palette = "grey"
      }
      aggregator = "sum"
    }
    marker {
      type = "error dashed"
      value = "y = 99.95"
      label = "99.95"
    }
    yaxis {
      min = "99"
      max = "100"
    }
  }

And in terraform.state it is shown as

"graph.1.yaxis.%": "2",
"graph.1.yaxis.max": "100",
"graph.1.yaxis.min": "99",

Terraform Version

v0.10.3

Affected Resource(s)

datadog_timeboard

Expected Behavior

The state file should have been modified with the new added configuration in the datadog timeboard

Actual Behavior

Terraform plan or apply is failing. The error reads json: cannot unmarshal string into Go struct field Yaxis.min of type float64

Steps to Reproduce

  1. Have an existent terraform state containing datadog timeboards
  2. Upgrade to the indicated version
  3. Run terraform plan or apply
@radeksimko radeksimko added the bug label Sep 14, 2017
@RodrigoBerto
Copy link
Author

any progress on this?

@nyanshak
Copy link
Contributor

I haven't been able to reproduce this (tried going from 0.10.2 to 0.10.3, as well as from 0.9.0 to 0.10.3). I'm not sure which datadog plugin version you were using, but I suspect this issue has been fixed. @RodrigoBerto, can you confirm and close or provide more info on the problem?

@davidalger
Copy link

davidalger commented Nov 13, 2017

I've run across this myself…and discovered it stems from the the yaxis config block generating different JSON than the Datadog UI does.

The following blip in the JSON will cause the import to fail.

  "yaxis": {
    "max": "100",
    "min": "0"
  }

The above is generated by the Datadog UI whereas Terraform is generating the following:

  "yaxis": {
    "max": 100,
    "min": 0
  }

This breaks the import as well as continued use of a Terraform plan. I.e. if I alter a time board from the Datadog UI, setting the y-axis values, the JSON will now have strings instead of floats resulting in the following output on a plan run:

datadog_timeboard.system_status: datadog_timeboard.system_status: json: cannot unmarshal string into Go struct field Yaxis.max of type float64

The Terraform docs still state these should be strings and strings are in fact what the HCL expects, but for some reason it would appear that a float is being used internally.

min - (Optional) Minimum bound for the graph's yaxis, a string.
max - (Optional) Maximum bound for the graph's yaxis, a string.

This is on Terraform v0.10.8 with terraform-provider-datadog_v1.0.0.

@NabilZaman
Copy link

NabilZaman commented Dec 6, 2017

I have also been running into this issue, has there been any progress on resolving this or any workarounds?
EDIT: Okay, well it seems the obvious workaround of removing the yaxis block from within the UI (I had to go into the JSON tab and delete that manually) works.
Would still be swell to be compatible with whatever remote state the datadog API generates.

@lachlancooper
Copy link
Contributor

This is being tracked on the vendored SDK here: zorkian/go-datadog-api#103

@robinbowes
Copy link

This looks similar to https://github.com/terraform-providers/terraform-provider-datadog/issues/10 which was fixed upstream, ie. Datadog fixed their API frontend to send int not string. Do they need to do the same here?

@johansnow
Copy link

This issue still remains in Datadog provider version 1.2.

nyanshak added a commit to nyanshak/terraform-provider-datadog that referenced this issue Sep 6, 2018
* v2.13.0 of go-datadog-api library adds a custom unmarshaller for Yaxis
struct, which can properly handle the issue where strings (e.g. "99")
for yaxis.max would cause the tf provider to bail out.
@nyanshak
Copy link
Contributor

nyanshak commented Sep 6, 2018

Raised #92 to fix this issue by bumping go-datadog-api library version number.

@masci
Copy link
Contributor

masci commented Oct 3, 2018

Closing since fix was implemented in #91 and released in 1.3.0

@masci masci closed this as completed Oct 3, 2018
@rodush
Copy link

rodush commented Jan 25, 2019

Reproduced in 1.6.0

@tomasaberg
Copy link

Hi!

I still have this problem in datadog v2.0.2

terraform providers -v
Terraform v0.12.3
+ provider.datadog v2.0.2

How I can reproduce this is:

  1. Create a simple screenboard
  2. Go to https://app.datadoghq.com/monitors/manage and check out your new dashboard.
  3. Click Edit
  4. Make no changes at all
  5. Press Save
  6. Run Terraform and receive this message.

Is there a workaround available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests