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

failed to create an incident #165

Closed
chunyanlv opened this issue Aug 27, 2019 · 7 comments · Fixed by #166
Closed

failed to create an incident #165

chunyanlv opened this issue Aug 27, 2019 · 7 comments · Fixed by #166

Comments

@chunyanlv
Copy link

Here is my code:

        opts := officialPD.CreateIncidentOptions{
                Type: "incident",
                Title: title,
                Service: &service,
                Body: &body,
                EscalationPolicy: &escalationPolicy,
        }
 _, err := client.CreateIncident(INCIDENT_FROM, &opts)

I have the title correctly set.
But I got the error like:

panic: Failed call API endpoint. HTTP response code: 400. Error: &{2001 Invalid Input Provided [Title cannot be empty.]}

Does anyone know what is wrong?

@joepurdy
Copy link
Contributor

Looks like a bug in the implementation of CreateIncident

func (c *Client) CreateIncident(from string, o *CreateIncidentOptions) (*Incident, error) {
	headers := make(map[string]string)
	headers["From"] = from
	resp, e := c.post("/incidents", o, &headers)
        .....
}

This is a bit different than other implementations, for example consider CreateIncidentNote:

func (c *Client) CreateIncidentNote(id string, note IncidentNote) error {
	data := make(map[string]IncidentNote)
	headers := make(map[string]string)
	headers["From"] = note.User.Summary

	data["note"] = note
	_, err := c.post("/incidents/"+id+"/notes", data, &headers)
	return err
}

The difference is that with CreateIncident the options are being passed directly as-is. Other places the options get placed under a named property like data["note"] = note

I'll open a PR with the fix shortly.

@snaveen
Copy link

snaveen commented Sep 6, 2019

I saw your fix. It would be really helpful for me if this gets merged. Is there any workaround till that?

@joepurdy
Copy link
Contributor

joepurdy commented Sep 6, 2019

@snaveen My PR being merged is up to the maintainers of PagerDuty/go-pagerduty

If you want to use my fork for the time being I've gone and merged my fix into master there: https://github.com/joepurdy/go-pagerduty

I'll do my best to keep the fork updated with upstream, but ultimately the best fix would be the maintainers merging the fix into upstream.

@snaveen
Copy link

snaveen commented Sep 7, 2019

Thanks @joepurdy

@theckman
Copy link
Collaborator

theckman commented Sep 9, 2019

I think I have merge access, let me see if I can do the needful tonight (Pacific time).

@snaveen
Copy link

snaveen commented Sep 18, 2019

@theckman could you help us on this?

@snaveen
Copy link

snaveen commented Sep 19, 2019

@ranjib Could you help us on this?

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

Successfully merging a pull request may close this issue.

4 participants