Skip to content

Conversation

mjlshen
Copy link
Contributor

@mjlshen mjlshen commented May 1, 2022

The PagerDuty API is happy when only Type is set to omitempty, but I think it makes sense to do the same for AlertGroupParamsConfig as well as change it to be a pointer so that it gets a nil value instead of the zero value for all the config values in case the api checks those values in the future.

func main() {
	client := pagerduty.NewClient(authToken)
	svc, err := client.GetServiceWithContext(context.TODO(), serviceId, nil)
	if err != nil {
		panic(err)
	}

        // Whether there's no value from GetService or if it's set
	svc.AlertGroupingParameters.Type = ""

	_, err := client.UpdateServiceWithContext(context.TODO(), *svc)
	if err != nil {
                 // Results in panic: HTTP response failed with status code 400,
                 // message: Invalid Input Provided (code: 2001): Alert grouping parameters is invalid.
		panic(err)
	}
}

Fixes #438

Converting to a pointer and adding omitempty to AlertGroupingParameters
fields
@mjlshen
Copy link
Contributor Author

mjlshen commented Jun 7, 2022

@theckman @ChuckCrawford not sure if any of you have cycles to review this? Thanks!

@ChuckCrawford ChuckCrawford self-requested a review July 11, 2022 13:33
@ChuckCrawford
Copy link
Collaborator

Thank you for your help with this @mjlshen .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This PR contains a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chaining GetService and UpdateService fails when AlertGroupingParameters is omitted
2 participants