diff --git a/pkg/apis/pipeline/v1/task_validation_test.go b/pkg/apis/pipeline/v1/task_validation_test.go index 86b5511c83f..45e637fdd0d 100644 --- a/pkg/apis/pipeline/v1/task_validation_test.go +++ b/pkg/apis/pipeline/v1/task_validation_test.go @@ -987,6 +987,28 @@ func TestTaskSpecValidateError(t *testing.T) { Message: `variable type invalid in "$(params.gitrepo[*])"`, Paths: []string{"steps[0].args[0]"}, }, + }, { + name: "non-existent individual key of an object param is used in task step", + fields: fields{ + Params: []v1.ParamSpec{{ + Name: "gitrepo", + Type: v1.ParamTypeObject, + Properties: map[string]v1.PropertySpec{ + "url": {}, + "commit": {}, + }, + }}, + Steps: []v1.Step{{ + Name: "do-the-clone", + Image: "some-git-image", + Args: []string{"$(params.gitrepo.non-exist-key)"}, + WorkingDir: "/foo/bar/src/", + }}, + }, + expectedError: apis.FieldError{ + Message: `non-existent variable in "$(params.gitrepo.non-exist-key)"`, + Paths: []string{"steps[0].args[0]"}, + }, }, { name: "Inexistent param variable in volumeMount with existing", fields: fields{ diff --git a/pkg/apis/pipeline/v1beta1/task_validation_test.go b/pkg/apis/pipeline/v1beta1/task_validation_test.go index 835f0c3d3a2..75e6b3a5a39 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/task_validation_test.go @@ -1099,6 +1099,28 @@ func TestTaskSpecValidateError(t *testing.T) { Message: `variable type invalid in "$(params.gitrepo[*])"`, Paths: []string{"steps[0].args[0]"}, }, + }, { + name: "non-existent individual key of an object param is used in task step", + fields: fields{ + Params: []v1beta1.ParamSpec{{ + Name: "gitrepo", + Type: v1beta1.ParamTypeObject, + Properties: map[string]v1beta1.PropertySpec{ + "url": {}, + "commit": {}, + }, + }}, + Steps: []v1beta1.Step{{ + Name: "do-the-clone", + Image: "some-git-image", + Args: []string{"$(params.gitrepo.non-exist-key)"}, + WorkingDir: "/foo/bar/src/", + }}, + }, + expectedError: apis.FieldError{ + Message: `non-existent variable in "$(params.gitrepo.non-exist-key)"`, + Paths: []string{"steps[0].args[0]"}, + }, }, { name: "Inexistent param variable in volumeMount with existing", fields: fields{