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

Accept "null" in monitor NoDataTimeframe #129

Merged
merged 2 commits into from
Nov 28, 2017

Conversation

dtan4
Copy link
Contributor

@dtan4 dtan4 commented Nov 6, 2017

Why

If the monitor is configured not to notify data missing, GetMonitor API returns null in no_data_timeframe field.
Therefore NoDataTimeframe.UnmarshalJSON tries to parse "null" as Int, then it returns error.

how to reproduce

package main

import (
	"os"

	"github.com/k0kubun/pp"
	"github.com/zorkian/go-datadog-api"
)

const (
	monitorID = 123456 // your monitor ID which does not notify data missing
)

func main() {
	apiKey, appKey := os.Getenv("DATADOG_API_KEY"), os.Getenv("DATADOG_APP_KEY")
	client := datadog.NewClient(apiKey, appKey)

	mon, err := client.GetMonitor(monitorID)
	if err != nil {
		panic(err)
	}

	pp.Println(mon)
}
$ go run hoge.go
panic: strconv.ParseInt: parsing "null": invalid syntax

goroutine 1 [running]:
main.main()
        /Users/dtan4/src/github.com/dtan4/terraforming-datadog/hoge.go:20 +0x1e1
exit status 2

What

Accept nil in no_data_timeframe and return empty value.

@philwhln
Copy link

philwhln commented Nov 9, 2017

I'm hitting this issue too. This change makes sense to me.

@ojongerius ojongerius added the bug label Nov 10, 2017
@ojongerius
Copy link
Collaborator

@dtan4 awesome! Would you be able to add a test to /integration/monitors_test.go?

@fprimex
Copy link

fprimex commented Nov 27, 2017

Hi, as mentioned over in the Terraform Datadog provider issues ( https://github.com/terraform-providers/terraform-provider-datadog/issues/31 ), this PR would resolve an issue importing and converging resources when using Terraform. Is there a timeline for getting this merged? Is there any engineering effort that needs to be contributed to to get this accepted and released? Thanks!

@dtan4
Copy link
Contributor Author

dtan4 commented Nov 28, 2017

Sorry for late! I added integration testcase to verify this change.

@ojongerius ojongerius merged commit a117c6a into zorkian:master Nov 28, 2017
@dtan4 dtan4 deleted the accept-null-no-data-timeframe branch November 28, 2017 09:34
@fprimex
Copy link

fprimex commented Nov 30, 2017

Awesome :) would it be possible to ping us in the TF issue that was linked when a release is made? I'll be keeping an eye out, but we'll probably do a new release immediately after it is available.

@ojongerius
Copy link
Collaborator

ojongerius commented Dec 1, 2017

@fprimex: I just released https://github.com/zorkian/go-datadog-api/releases/tag/v2.6 and gave a heads up in https://github.com/terraform-providers/terraform-provider-datadog/issues/31

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

Successfully merging this pull request may close these issues.

4 participants