go-github: tests/fields: False positive for fields with null values, reported as "missing" incorrectly.
There appears to be a bug in the ./tests/fields
test/utility, causing some fields to be falsely reported as “missing”.
For example, in the following test case:
{"repos/google/go-github/issues/1", &github.Issue{}},
The real GitHub API response from https://api.github.com/repos/google/go-github/issues/1 includes:
...
"site_admin": false
}
],
"milestone": null,
"comments": 2,
"created_at": "2013-05-30T18:35:59Z",
"updated_at": "2013-08-20T22:47:14Z",
...
Note that the value of milestone
is null
.
The corresponding struct field Issue.Milestone
exists:
But the output from the fields test incorrectly reports:
...
*github.Issue missing field for key: milestone (example value: <nil>)
...
I think it’s because the null value gets dropped when JSON marshalling the Issue
struct, because of ,omitempty
option.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 15 (7 by maintainers)
No problem, that’s completely acceptable. Even if you don’t succeed, you’ll have tried, perhaps learned something, and maybe will succeed in the end. If you only start things you know you’ll succeed at, you won’t be able to start many things.
On the contrary, I gave it a shot, and had a rough prototype, but see the TODOs, many of them are “figure out the general high-level approach”, etc. So figuring out the exact plan is still a task to be done.
Sounds great!
I won’t be able to dig deep into this issue until at least the beginning of the new year. It is a 5-year-old issue and is probably not a very high priority, so I would say to give it your best shot and report your findings to hopefully move the issue forward somewhat. Thanks.
@VUHAILAM - this issue is yours. Thank you!
Thank you for your encouragement.
I take your point though, this is proving harder than I thought. I’m going to keep trying but I wouldn’t suggest anyone hold their breath for my fix.
Really, thank you.
Thanks for getting back to me.
I’m very new to Go (and OS contributing) so I might not succeed. At first read it looked like you had figured out the solution and just needed someone to do the leg work which is why I thought it looked doable.
I’ll definitely check in before submitting any code.
Thanks,