-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat!: Add support for multi-select Custom Properties #3200
feat!: Add support for multi-select Custom Properties #3200
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3200 +/- ##
==========================================
- Coverage 97.72% 92.92% -4.80%
==========================================
Files 153 171 +18
Lines 13390 11582 -1808
==========================================
- Hits 13085 10763 -2322
- Misses 215 726 +511
- Partials 90 93 +3 ☔ View full report in Codecov by Sentry. |
Yes, if I remember correctly, we handle situations like this in various ways:
So I'm fine with this method. You could additionally define two new structs |
That makes sense, thank you for the explanation and the breakdown. I'm fine with the current solution as is if we want to go with that, at some point I did something similar to having two new structs but ended up deciding to move back to trying the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @arymoraes!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
Thank you, @valbeat ! |
switch v := aux.Value.(type) { | ||
case nil: | ||
cpv.Value = nil | ||
case string: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do boolean custom properties come through as a string as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they come as string
from the GitHub API:
{
"property_name": "boolean_prop",
"value": "true"
},
Fixes #3198.
BREAKING CHANGE:
CustomPropertyValue.Value
is changed from*string
tointerface{}
to supportstring
and[]string
values.So the problem here is that the GitHub custom properties
value
can come in either as astring
(for all nonmulti_select
properties), or as a[]string
in amulti_select
property.The issue is happening because we were trying to unmarshal it but always expecting a
string
for the Value.My solution was to make value an
interface{}
type that implements aUnmarshalJSON
to handle both scenarios. While this works, we end up losing the auto generatedGetValue()
accessor. Another thing I was unsure is that I saw on other places and on the tests for this that we use a pointer to the value, but I changed it to the value itself on the Unmarshal call since we lose the accessor, not sure if this is correct.Another solution I played with was using
json.RawMessage
, I could not make it fully work (I can give it another try), but at least we did lose the auto generatedGetValue
accessor there, would this be a more adequate solution?