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

Bugfix json-marshal collaborators in Ticket #206

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

frairon
Copy link
Contributor

@frairon frairon commented Aug 2, 2021

Many thanks for the library!

Here's a PR to fix a small bug when json-marshalling a Ticket.

This happens, e.g. when creating a Ticket in ticket.go:242
which marshals the passed Ticket in zendesk.go:117
The json sent to the server is then something like this:

{
  "ticket": {
    "//": "...",
    "collaborators": {},
    "//": "...",
  }
}

Although it should be "collaborators" : [] because it's clearly a list.
The reason is, that json.Marshal(...) is called on a value of Ticket instead of a pointer, i.e. the function func (c * Collaborators) MarshalJSON() ([]byte, error) is never called.

In production there is no problem because Zendesk tolerates the data.
In our application however we mock Zendesk's http interface for unit testing. In the mock we'd like to json.Unmarshal the received data into a Ticket to send it back to the caller. This fails with json: cannot unmarshal object into Go struct field Ticket.ticket.collaborators of type []interface {}.
I'd like to fix that.

@nukosuke nukosuke added the Bug Something isn't working label Aug 2, 2021
@nukosuke
Copy link
Owner

nukosuke commented Aug 2, 2021

@frairon.

omg, it's definitely a bug.
After merge, I'll release v0.9.4 which includes this pr. Please try it.

Thank you for that 👍

Copy link
Owner

@nukosuke nukosuke left a comment

Choose a reason for hiding this comment

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

LGTM

@nukosuke nukosuke added this to the v0.9.4 milestone Aug 2, 2021
@nukosuke nukosuke merged commit 0cf5061 into nukosuke:master Aug 2, 2021
@frairon
Copy link
Contributor Author

frairon commented Aug 2, 2021

@nukosuke Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants