Skip to content

Commit 6d4a99e

Browse files
committed
Match error in tests and add changelog
1 parent fb2805e commit 6d4a99e

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.chloggen/mx-psi_error-map.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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: enhancement
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: Surface YAML parsing errors when they happen at the top-level.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12180]
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+
This adds context to some instances of the error "retrieved value (type=string) cannot be used as a Conf", which typically happens because of invalid YAML documents
20+
21+
# Optional: The change log or logs in which this entry should be included.
22+
# e.g. '[user]' or '[user, api]'
23+
# Include 'user' if the change is relevant to end users.
24+
# Include 'api' if there is a change to a library API.
25+
# Default: '[user]'
26+
change_logs: []

confmap/provider_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func TestNewRetrievedFromYAMLInvalidYAMLBytes(t *testing.T) {
135135

136136
_, err = ret.AsConf()
137137
require.Error(t, err)
138+
assert.EqualError(t, err,
139+
"retrieved value (type=string) cannot be used as a Conf: assuming string type since contents are not valid YAML: yaml: line 1: did not find expected node content",
140+
)
138141

139142
str, err := ret.AsString()
140143
require.NoError(t, err)
@@ -151,6 +154,7 @@ func TestNewRetrievedFromYAMLInvalidAsMap(t *testing.T) {
151154

152155
_, err = ret.AsConf()
153156
require.Error(t, err)
157+
assert.EqualError(t, err, "retrieved value (type=string) cannot be used as a Conf")
154158

155159
str, err := ret.AsString()
156160
require.NoError(t, err)

otelcol/collector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func TestCollectorStartInvalidConfig(t *testing.T) {
312312
ConfigProviderSettings: newDefaultConfigProviderSettings(t, []string{filepath.Join("testdata", "otelcol-invalid.yaml")}),
313313
})
314314
require.NoError(t, err)
315-
assert.Error(t, col.Run(context.Background()))
315+
assert.EqualError(t, col.Run(context.Background()), "invalid configuration: service::pipelines::traces: references processor \"invalid\" which is not configured")
316316
}
317317

318318
func TestNewCollectorInvalidConfigProviderSettings(t *testing.T) {

0 commit comments

Comments
 (0)