-
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
Config unmarshalling doesn't work properly for slice values #4001
Labels
bug
Something isn't working
help wanted
Good issue for contributors to OpenTelemetry Service to pick up
Comments
dmitryax
changed the title
Config unmarshalling doesn't work properly with slices as values
Config unmarshalling doesn't work properly for slice values
Sep 9, 2021
mcdoker18
added a commit
to mcdoker18/opentelemetry-collector
that referenced
this issue
Sep 27, 2022
mapstructure library doesn't override full slice during unmarshalling. Origin issue: mitchellh/mapstructure#74 (comment) To address this we zeroes every slice before unmarshalling unless user provided slice is nil.
mcdoker18
added a commit
to mcdoker18/opentelemetry-collector
that referenced
this issue
Sep 29, 2022
mapstructure library doesn't override full slice during unmarshalling. Origin issue: mitchellh/mapstructure#74 (comment) To address this we zeroes every slice before unmarshalling unless user provided slice is nil.
mcdoker18
added a commit
to mcdoker18/opentelemetry-collector
that referenced
this issue
Sep 30, 2022
mapstructure library doesn't override full slice during unmarshalling. Origin issue: mitchellh/mapstructure#74 (comment) To address this we zeroes every slice before unmarshalling unless user provided slice is nil.
mcdoker18
added a commit
to mcdoker18/opentelemetry-collector
that referenced
this issue
Oct 15, 2022
mapstructure library doesn't override full slice during unmarshalling. Origin issue: mitchellh/mapstructure#74 (comment) To address this we zeroes every slice before unmarshalling unless user provided slice is nil.
mcdoker18
added a commit
to mcdoker18/opentelemetry-collector
that referenced
this issue
Oct 17, 2022
mapstructure library doesn't override full slice during unmarshalling. Origin issue: mitchellh/mapstructure#74 (comment) To address this we empty every slice before unmarshalling unless user provided slice is nil.
dmitryax
added
the
help wanted
Good issue for contributors to OpenTelemetry Service to pick up
label
Apr 3, 2023
codeboten
pushed a commit
that referenced
this issue
Sep 11, 2023
fix the bug of unmarshalling slice values for package confmap Fixes #4001 --------- Signed-off-by: Ziqi Zhao <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
help wanted
Good issue for contributors to OpenTelemetry Service to pick up
Describe the bug
If we have a default config for a component where there is a slice value with 2 and more item, there is no way to override that value with a smaller slice.
The problem is that mapstructure.decodeMap func that we use for unmarshalling compares elements of the slice one by one and does not override the length of the result. It leads to the problem that we cannot override a default slice value with a slice of smaller size.
This is an unexpected behaviour for users. We should be able to fully override default slice values.
Steps to reproduce
Real example is https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/dotnetdiagnosticsreceiver configuration:
Try to override the
counters
value with a 1-item slice like this:What did you expect to see?
A slice config value should be fully overridden. In the example above, we should get
counters: ["MyCounters"]
What did you see instead?
Only subset of the default slice items are overridden, the rest of the default slice stays the same. In the example above, we get
counters: ["MyCounters", "Microsoft.AspNetCore.Hosting"]
The text was updated successfully, but these errors were encountered: