Skip to content

Config unmarshalling doesn't work properly for slice values  #4001

Closed
@dmitryax

Description

@dmitryax

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:

receivers:
  dotnet_diagnostics:
    counters: ["MyCounters"]

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"]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedGood issue for contributors to OpenTelemetry Service to pick up

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions