Skip to content

Commit 727ae96

Browse files
authored
[confmap] use DeepEqual when using confmap.enableMergeAppendOption (#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.-->
1 parent ca612c0 commit 727ae96

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: confmap
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Use reflect.DeepEqual to avoid panic when confmap.enableMergeAppendOption feature gate is enabled.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12932]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

confmap/merge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func mergeSlice(src, dest reflect.Value) any {
6363

6464
func isPresent(slice reflect.Value, val reflect.Value) bool {
6565
for i := 0; i < slice.Len(); i++ {
66-
if slice.Index(i).Equal(val) {
66+
if reflect.DeepEqual(val.Interface(), slice.Index(i).Interface()) {
6767
return true
6868
}
6969
}

confmap/testdata/merge-append-scenarios.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,30 @@
669669
receivers: [nop]
670670
processors: [attributes/example, nop2]
671671
exporters: [nop]
672+
- name: merge-mode-map
673+
configs:
674+
-
675+
processors:
676+
resource:
677+
attributes:
678+
- key: deployment.region
679+
value: "nl"
680+
action: upsert
681+
-
682+
processors:
683+
resource:
684+
attributes:
685+
- key: app
686+
value: "foo"
687+
action: upsert
688+
689+
expected:
690+
processors:
691+
resource:
692+
attributes:
693+
- key: deployment.region
694+
value: "nl"
695+
action: upsert
696+
- key: app
697+
value: "foo"
698+
action: upsert

0 commit comments

Comments
 (0)