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

Add JSON tag for ErrorResponse #2641

Merged

Conversation

migueleliasweb
Copy link
Contributor

@migueleliasweb migueleliasweb commented Jan 24, 2023

Fixes: #2640.

@codecov
Copy link

codecov bot commented Jan 24, 2023

Codecov Report

Merging #2641 (bafa709) into master (36c47d1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2641   +/-   ##
=======================================
  Coverage   98.05%   98.05%           
=======================================
  Files         130      130           
  Lines       11242    11244    +2     
=======================================
+ Hits        11023    11025    +2     
  Misses        150      150           
  Partials       69       69           
Impacted Files Coverage Δ
github/github.go 97.46% <100.00%> (+<0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 25, 2023

Why is this even needed?
What problem is it solving?

Fixes: #2640.

@gmlewis gmlewis added waiting for reply DO NOT MERGE Do not merge this PR. and removed waiting for reply DO NOT MERGE Do not merge this PR. labels Jan 25, 2023
github/github.go Outdated
Response *http.Response // HTTP response that caused this error
Message string `json:"message"` // error message
Errors []Error `json:"errors"` // more detail on individual errors
Response *http.Response `json:"omitempty"` // HTTP response that caused this error
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've never seen a bare "omitempty" before, so can we please name it as "response"?

Suggested change
Response *http.Response `json:"omitempty"` // HTTP response that caused this error
Response *http.Response `json:"response,omitempty"` // HTTP response that caused this error

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'm fine adding the name of the field. But I wonder in this case if it might needs to be Response to maintain compatibility with the current code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are saying it should be "Response" with a capital-R ?
When you say "compatibility with the current code", do you mean the "go-github" repo?
If so, I'm not sure why we would need to capitalize the R, and I would think the lower-case version should be fine.

Alternatively, another approach might be to simply use json:"-" and always leave it out... but I'll let you decide if that is the best option for compatibility with your mocking package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Glenn, I actually liked the idea of going with json:"-". Let me test a few things and I will come back to you.

Thanks for the swift responses!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @gmlewis , it seems the json:"-" should work just fine. I will update the PR soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@migueleliasweb migueleliasweb force-pushed the add-missing-json-tag-errorresponse branch from c93ce7b to 2ea160d Compare January 26, 2023 11:36
@migueleliasweb migueleliasweb force-pushed the add-missing-json-tag-errorresponse branch from 2ea160d to bafa709 Compare January 26, 2023 11:39
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @migueleliasweb !
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jan 26, 2023
@migueleliasweb
Copy link
Contributor Author

It's always a pleasure, @gmlewis 😃 . Is there someone I could ping here to get this going?

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 26, 2023

@Parker77 - do you have time for an LGTM+Approval, please?

Copy link

@Parker77 Parker77 left a comment

Choose a reason for hiding this comment

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

LGTM!

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 26, 2023

Thank you, @Parker77!
Merging.

@gmlewis gmlewis merged commit d386e49 into google:master Jan 26, 2023
@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Jan 26, 2023
@migueleliasweb
Copy link
Contributor Author

Btw, merging this fixed the default error formatting issue on go-github-mock 😃 . Thanks all!

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.

Possible missed json tag in github.ErrorResponse
3 participants