diff --git a/pkg/fieldpath/fieldpath.go b/pkg/fieldpath/fieldpath.go index b997751ec81..a104a70bc73 100644 --- a/pkg/fieldpath/fieldpath.go +++ b/pkg/fieldpath/fieldpath.go @@ -46,7 +46,7 @@ func FormatMap(m map[string]string) (fmtStr string) { func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error) { accessor, err := meta.Accessor(obj) if err != nil { - return "", nil + return "", err } if path, subscript, ok := SplitMaybeSubscriptedPath(fieldPath); ok { diff --git a/pkg/fieldpath/fieldpath_test.go b/pkg/fieldpath/fieldpath_test.go index efa8e99477f..0aa6ad56d72 100644 --- a/pkg/fieldpath/fieldpath_test.go +++ b/pkg/fieldpath/fieldpath_test.go @@ -33,9 +33,10 @@ func TestExtractFieldPathAsString(t *testing.T) { expectedMessageFragment string }{ { - name: "not an API object", - fieldPath: "metadata.name", - obj: "", + name: "not an API object", + fieldPath: "metadata.name", + obj: "", + expectedMessageFragment: "object does not implement the Object interfaces", }, { name: "ok - namespace",