-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct missing field(s) error #2295
Changes from all commits
3061def
9c8dc17
a2b3f19
431c0d5
ca0d345
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ import ( | |
"github.com/tektoncd/pipeline/pkg/apis/validate" | ||
"github.com/tektoncd/pipeline/pkg/substitution" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/equality" | ||
"k8s.io/apimachinery/pkg/util/validation" | ||
"knative.dev/pkg/apis" | ||
) | ||
|
@@ -40,9 +39,6 @@ func (t *Task) Validate(ctx context.Context) *apis.FieldError { | |
} | ||
|
||
func (ts *TaskSpec) Validate(ctx context.Context) *apis.FieldError { | ||
if equality.Semantic.DeepEqual(ts, &TaskSpec{}) { | ||
return apis.ErrMissingField(apis.CurrentField) | ||
} | ||
|
||
if len(ts.Steps) == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will happen if ts is a nil pointer? Is there protection against that elsewhere in the codebase that will prevent it from happening? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way the code is now, the callers of the validate methods appear to be responsible for checking for nil. For example in taskrun_validation:
I haven't seen a nil check inside any of the validation methods I've looked at. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is always the case though - see Task.Validate a few lines above this one: func (t *Task) Validate(ctx context.Context) *apis.FieldError {
if err := validate.ObjectMetadata(t.GetObjectMeta()); err != nil {
return err.ViaField("metadata")
}
return t.Spec.Validate(ctx)
} I'm fine to remove the check in TaskSpec.Validate if we're absolutely sure that there won't be usages. But if we're cherry-picking this into the 0.11 branch just before we cut the beta and we're not 100% sure then I'd prefer we postpone this change to another PR. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Also, I believe - though I could be completely wrong! - that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the first thing I did was to check if the DeepEqual check was catching a nil. I put the check back and forced ts to be nil. It fell through the DeepEqual check and panicked on the ts.Steps reference. So I don't believe I'm introducing an exposure. It was there before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (fwiw I don't think this is fixing an urgent problem so it's fine to postpone merging it to post 0.11) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 understood, thanks for testing the nil case and correcting my assumption here. |
||
return apis.ErrMissingField("steps") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 🙏 thankyou!