Skip to content

Panic when using confmap.enableMergeAppendOption #12932

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

Closed
mcarton opened this issue Apr 28, 2025 · 1 comment · Fixed by #12952
Closed

Panic when using confmap.enableMergeAppendOption #12932

mcarton opened this issue Apr 28, 2025 · 1 comment · Fixed by #12952
Labels
bug Something isn't working

Comments

@mcarton
Copy link

mcarton commented Apr 28, 2025

Component(s)

No response

What happened?

Describe the bug
The collector panics when using confmap.enableMergeAppendOption.

Steps to reproduce
Running print-initial-config with confmap.enableMergeAppendOption panics as such:

$ cat /tmp/generic.yaml
processors:
  resource:
    attributes:
      - key: deployment.region
        value: "nl"
        action: upsert
$ cat /tmp/host-specific.yaml 
processors:
  resource:
    attributes:
      - key: app
        value: "foo"
        action: upsert
$ otelcol-contrib print-initial-config --feature-gates=otelcol.printInitialConfig,confmap.enableMergeAppendOption --config /tmp/host-specific.yaml --config /tmp/generic.yaml
panic: reflect.Value.Equal: values of type map[string]interface {} are not comparable

goroutine 1 [running]:
reflect.Value.Equal({0x41afea0?, 0xc0008ec980?, 0x0?}, {0x41afea0?, 0xc000918ce0?, 0x194?})
	reflect/value.go:3221 +0x6ec
go.opentelemetry.io/collector/confmap.isPresent({0x3fb0820?, 0xc000cf07e0?, 0x0?}, {0x41afea0?, 0xc000918ce0?, 0xc00086cfc8?})
	go.opentelemetry.io/collector/[email protected]/merge.go:66 +0xdb
go.opentelemetry.io/collector/confmap.mergeSlice({0x3fb0820?, 0xc000cf07b0?, 0xc000a36fd6?}, {0x3fb0820?, 0xc000c7fad0?, 0x0?})
	go.opentelemetry.io/collector/[email protected]/merge.go:56 +0x37a
go.opentelemetry.io/collector/confmap.mergeAppend(0x0?, 0xc0009043f0)
	go.opentelemetry.io/collector/[email protected]/merge.go:36 +0x1fc
go.opentelemetry.io/collector/confmap.mergeAppend(0xc000d1f518?, 0xc000904390)
	go.opentelemetry.io/collector/[email protected]/merge.go:39 +0x1dd
go.opentelemetry.io/collector/confmap.mergeAppend(0xc0009058f0?, 0xc0008eb290)
	go.opentelemetry.io/collector/[email protected]/merge.go:39 +0x1dd
github.com/knadh/koanf/v2.(*Koanf).merge(0xc0008eb320, 0xc0009058f0, 0xc0005858c8)
	github.com/knadh/koanf/[email protected]/koanf.go:408 +0xab
github.com/knadh/koanf/v2.(*Koanf).Load(0xc0008eb320, {0x51b87d8?, 0xc0005858b8?}, {0x0?, 0x0?}, {0xc000d1f808, 0x1, 0x41a2c5?})
	github.com/knadh/koanf/[email protected]/koanf.go:120 +0x12e
go.opentelemetry.io/collector/confmap.(*Conf).mergeAppend(0xc000142430, 0x51fe590?)
	go.opentelemetry.io/collector/[email protected]/confmap.go:184 +0x76
go.opentelemetry.io/collector/confmap.(*Resolver).Resolve(0xc000cdaee0, {0x51fe590, 0x77032c0})
	go.opentelemetry.io/collector/[email protected]/resolver.go:185 +0x2fb
go.opentelemetry.io/collector/otelcol.newConfigPrintSubCommand.func1(0xc0009c5208, {0xc000cd4870?, 0x4?, 0x49cdfee?})
	go.opentelemetry.io/collector/[email protected]/command_print.go:44 +0xf8
github.com/spf13/cobra.(*Command).execute(0xc0009c5208, {0xc000cd4820, 0x5, 0x5})
	github.com/spf13/[email protected]/command.go:1015 +0xa94
github.com/spf13/cobra.(*Command).ExecuteC(0xc0009c4608)
	github.com/spf13/[email protected]/command.go:1148 +0x40c
github.com/spf13/cobra.(*Command).Execute(0x4baf830?)
	github.com/spf13/[email protected]/command.go:1071 +0x13
main.runInteractive({0x4baf830, {{0x4a0005c, 0x10}, {0x4a72eb0, 0x27}, {0x49cface, 0x5}}, 0x0, {{{0x0, 0x0, ...}, ...}}, ...})
	go.opentelemetry.io/collector/cmd/builder/main.go:52 +0x5d
main.run(...)
	go.opentelemetry.io/collector/cmd/builder/main_others.go:10
main.main()
	go.opentelemetry.io/collector/cmd/builder/main.go:45 +0x2d8

What did you expect to see?
No panic. The lists should be merged, and the output should be something like:

processors:
  resource:
    attributes:
      - key: deployment.region
        value: "nl"
        action: upsert
      - key: app
        value: "foo"
        action: upsert

What did you see instead?
The collector panics.

Collector version

v0.124.0

Environment information

No response

OpenTelemetry Collector configuration

Log output

panic: reflect.Value.Equal: values of type map[string]interface {} are not comparable

goroutine 1 [running]:
reflect.Value.Equal({0x41afea0?, 0xc0008ec980?, 0x0?}, {0x41afea0?, 0xc000918ce0?, 0x194?})
	reflect/value.go:3221 +0x6ec
go.opentelemetry.io/collector/confmap.isPresent({0x3fb0820?, 0xc000cf07e0?, 0x0?}, {0x41afea0?, 0xc000918ce0?, 0xc00086cfc8?})
	go.opentelemetry.io/collector/[email protected]/merge.go:66 +0xdb
go.opentelemetry.io/collector/confmap.mergeSlice({0x3fb0820?, 0xc000cf07b0?, 0xc000a36fd6?}, {0x3fb0820?, 0xc000c7fad0?, 0x0?})
	go.opentelemetry.io/collector/[email protected]/merge.go:56 +0x37a
go.opentelemetry.io/collector/confmap.mergeAppend(0x0?, 0xc0009043f0)
	go.opentelemetry.io/collector/[email protected]/merge.go:36 +0x1fc
go.opentelemetry.io/collector/confmap.mergeAppend(0xc000d1f518?, 0xc000904390)
	go.opentelemetry.io/collector/[email protected]/merge.go:39 +0x1dd
go.opentelemetry.io/collector/confmap.mergeAppend(0xc0009058f0?, 0xc0008eb290)
	go.opentelemetry.io/collector/[email protected]/merge.go:39 +0x1dd
github.com/knadh/koanf/v2.(*Koanf).merge(0xc0008eb320, 0xc0009058f0, 0xc0005858c8)
	github.com/knadh/koanf/[email protected]/koanf.go:408 +0xab
github.com/knadh/koanf/v2.(*Koanf).Load(0xc0008eb320, {0x51b87d8?, 0xc0005858b8?}, {0x0?, 0x0?}, {0xc000d1f808, 0x1, 0x41a2c5?})
	github.com/knadh/koanf/[email protected]/koanf.go:120 +0x12e
go.opentelemetry.io/collector/confmap.(*Conf).mergeAppend(0xc000142430, 0x51fe590?)
	go.opentelemetry.io/collector/[email protected]/confmap.go:184 +0x76
go.opentelemetry.io/collector/confmap.(*Resolver).Resolve(0xc000cdaee0, {0x51fe590, 0x77032c0})
	go.opentelemetry.io/collector/[email protected]/resolver.go:185 +0x2fb
go.opentelemetry.io/collector/otelcol.newConfigPrintSubCommand.func1(0xc0009c5208, {0xc000cd4870?, 0x4?, 0x49cdfee?})
	go.opentelemetry.io/collector/[email protected]/command_print.go:44 +0xf8
github.com/spf13/cobra.(*Command).execute(0xc0009c5208, {0xc000cd4820, 0x5, 0x5})
	github.com/spf13/[email protected]/command.go:1015 +0xa94
github.com/spf13/cobra.(*Command).ExecuteC(0xc0009c4608)
	github.com/spf13/[email protected]/command.go:1148 +0x40c
github.com/spf13/cobra.(*Command).Execute(0x4baf830?)
	github.com/spf13/[email protected]/command.go:1071 +0x13
main.runInteractive({0x4baf830, {{0x4a0005c, 0x10}, {0x4a72eb0, 0x27}, {0x49cface, 0x5}}, 0x0, {{{0x0, 0x0, ...}, ...}}, ...})
	go.opentelemetry.io/collector/cmd/builder/main.go:52 +0x5d
main.run(...)
	go.opentelemetry.io/collector/cmd/builder/main_others.go:10
main.main()
	go.opentelemetry.io/collector/cmd/builder/main.go:45 +0x2d8

Additional context

No response

@mcarton mcarton added the bug Something isn't working label Apr 28, 2025
github-merge-queue bot pushed a commit that referenced this issue May 1, 2025
…12952)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

`Equal(..)` panics when we're comparing maps. Use `reflect.DeepEqual`
instead. It behaves same way as `Equal` for types such as `int`,
`string`, `float` etc, but compares individual elements for maps as
well.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes
#12932

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Added a scenario

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->
@VihasMakwana
Copy link
Contributor

@mcarton it should be fixed in upcoming release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants