-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[WIP][confmap] Enable decoding nil values in confmap #11734
base: main
Are you sure you want to change the base?
[WIP][confmap] Enable decoding nil values in confmap #11734
Conversation
Signed-off-by: Mahad Zaryab <[email protected]>
f4a9651
to
75840e6
Compare
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
to.Set(reflect.MakeSlice(to.Type(), from.Len(), from.Cap())) | ||
if !from.IsNil() { | ||
to.Set(reflect.MakeSlice(to.Type(), from.Len(), from.Cap())) | ||
} | ||
} | ||
|
||
return from.Interface(), nil |
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.
why are you not changing this to from
? That's the main change that needs to be applied across all hooks, otherwise you never know under which condition they might return untyped nil and break the chain.
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: Mahad Zaryab <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11734 +/- ##
==========================================
- Coverage 91.61% 91.60% -0.01%
==========================================
Files 443 443
Lines 23770 23778 +8
==========================================
+ Hits 21776 21781 +5
- Misses 1620 1622 +2
- Partials 374 375 +1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
@@ -33,8 +33,7 @@ func TestLoadConf(t *testing.T) { | |||
func TestToStringMapSanitizeEmptySlice(t *testing.T) { | |||
cfg, err := LoadConf(filepath.Join("testdata", "empty-slice.yaml")) | |||
require.NoError(t, err) | |||
var nilSlice []interface{} | |||
assert.Equal(t, map[string]any{"slice": nilSlice}, cfg.ToStringMap()) | |||
assert.Equal(t, map[string]any{"slice": []interface{}{}}, cfg.ToStringMap()) |
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.
@yurishkuro What do you think of the change to this expectation here? It looks like it was conflicting with rest of the decoding flow. This is what empty-slice.yaml
looks like:
slice: [] # empty slices are sanitized to nil in ToStringMap
Given that slice
is explicitly identified, shouldn't slice
be empty instead of nil?
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.
according to the comment in the fixture the current test is as expected. Does it not contradict the description of the hook?
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.
if there is indeed a contradiction, I would suggest opening a ticket with description, to let the maintainers opine what behavior they expect.
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.
PR is up at #11755 for the patch
a082c3b
to
4a58881
Compare
Signed-off-by: Mahad Zaryab <[email protected]>
ac3972a
to
57ffb80
Compare
Description
Optional
unmarshaller in WIP do not merge - optional config fields #10260. This PR enables the decoding of nil values inconfmap
to unblock the enablement of optional configs.Link to tracking issue
Towards ##10266
Testing
Documentation