Skip to content

Commit e4206a5

Browse files
committed
report origin of yaml parsing error
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent a42e757 commit e4206a5

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ func loadYamlFile(ctx context.Context,
509509
break
510510
}
511511
if err != nil {
512-
return nil, nil, err
512+
return nil, nil, fmt.Errorf("failed to parse %s: %w", file.Filename, err)
513513
}
514514
processor = reset
515515
if err := processRawYaml(raw, processor); err != nil {

loader/loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ func TestDecodeErrors(t *testing.T) {
990990

991991
configDetails := buildConfigDetails(dict, nil)
992992
_, err := LoadWithContext(context.TODO(), configDetails)
993-
assert.Error(t, err, "yaml: line 4: found a tab character that violates indentation")
993+
assert.Error(t, err, "failed to parse filename0.yml: yaml: line 4: found a tab character that violates indentation")
994994
}
995995

996996
func TestBuildProperties(t *testing.T) {

loader/merge_reset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ func Test_DuplicateReset(t *testing.T) {
7979
}, func(options *Options) {
8080
options.SkipNormalization = true
8181
})
82-
assert.Error(t, err, "line 6: mapping key \"command\" already defined at line 5")
82+
assert.Error(t, err, "failed to parse duplicate.yml: line 6: mapping key \"command\" already defined at line 5")
8383
}

loader/reset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ x-healthcheck: &healthcheck
163163
<<: *healthcheck
164164
`,
165165
expectError: true,
166-
errorMsg: "cycle detected: node at path x-healthcheck.egress-service.egress-service references node at path x-healthcheck.egress-service",
166+
errorMsg: "failed to parse (inline): cycle detected: node at path x-healthcheck.egress-service.egress-service references node at path x-healthcheck.egress-service",
167167
},
168168
}
169169

0 commit comments

Comments
 (0)