Skip to content

Fix ResponderRequest unmarshalling of IncidentResponders #493

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

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

allyjweir
Copy link
Contributor

This PR fixes an unmarshalling bug that was found while trying to use the ResponderRequestWithContext method on the client.

The response that the API returns is subtly different to the one which the client library is expecting. Within the responder_request_target object, the client library expects a key called incident_responders. However when interacting with the API directly, this key is actually incidents_responders. Note the additional s which pluralises 'incident'.

Impact

This meant that whenever you made a responder request via the client library, it would succeed but the response would only be partial. That meant you could not retrieve any of the information about the responders which your request had added to an incident.

A note on API documentation

Please note that there is an inconsistency in the PagerDuty API documentation for this endpoint.

  • In the written documentation it refers to: incident_responders
  • In the 'response example', it correctly refers to: incidents_responders

This commit also tweaks the json key name as the previous key did not
match the key used in production.
@@ -659,7 +659,7 @@ type ResponderRequestResponse struct {
// ResponderRequestTarget specifies an individual target for the responder request.
type ResponderRequestTarget struct {
APIObject
Responders IncidentResponders `json:"incident_responders,omitempty"`
Responders []IncidentResponders `json:"incidents_responders,omitempty"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider if the IncidentResponders type should be renamed IncidentResponder but decided to keep this PR to the minimum diff and not to break the interface

@ChuckCrawford ChuckCrawford self-requested a review August 15, 2023 15:24
@ChuckCrawford ChuckCrawford self-assigned this Aug 15, 2023
@ChuckCrawford
Copy link
Collaborator

Thanks for submitting this @allyjweir. Just following up on something internally and then we will get this merged.

@ChuckCrawford ChuckCrawford merged commit c1b5040 into PagerDuty:main Aug 16, 2023
gringus pushed a commit to gringus/go-pagerduty that referenced this pull request Jan 26, 2024
This commit also tweaks the json key name as the previous key did not
match the key used in production.
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 this pull request may close these issues.

2 participants