-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[confmap] Return nil map if original map was nil #13161
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (68.96%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #13161 +/- ##
==========================================
- Coverage 91.29% 91.27% -0.02%
==========================================
Files 509 509
Lines 28735 28759 +24
==========================================
+ Hits 26233 26251 +18
- Misses 1988 1993 +5
- Partials 514 515 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
} else if v.Value == nil { | ||
// If the value is nil, return a new empty Conf. | ||
c := New() | ||
c.isNil = true | ||
return c, nil | ||
} | ||
// override data with the original value to make the error message more informative. | ||
data = v.Value |
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.
This is tested in the nil_test.go
file in the end to end tests, but CodeCov doesn't know that since that is a separate module
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.
Are you sure about that? Running the test in a debugger, it looks like data
is never an expandedValue
.
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.
Sorry nevermind, looks like I was looking at the wrong test in that file.
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.
LGTM, just a few nitpicks, although I would want a second approval, in case others have strong objections to returning nil
from a function which did not previously, even if it causes no issues in contrib.
Yes, I will wait. The obvious alternative would be to keep the behavior of |
Description
Amends
ToStringMap
so that it returnsmap[string]any(nil)
if the map used to create thisConf
was nil. Currently it returns an empty map.I consider this a bug since, while not explicitly undocumented, I would expect the following two properties to be true, and they were not before this change:
m
withoutexpandedValue
s,NewFromStringMap(m).ToStringMap(m) == m
m
withoutexpandedValue
s and anypath
referencing an existing key inm
with amap[string]any
value,NewFromStringMap(m).Sub(path) == m[path[0]][path[1]][...][path[N]]
Link to tracking issue
I need this to be able to distinguish between
and
which currently have different behaviors when mapping to pointers.
The goal is to be able to do #13168